/* ============================================================
   PILOT PME — style.css
   Design SaaS moderne, responsive, sans framework
   ============================================================ */

/* ---- RESET & BASE ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue-night: #1a2744;
  --blue-mid:   #2d4a8a;
  --blue-light: #4f79c8;
  --accent:     #6c5ce7;
  --accent-soft:#ede9fe;
  --bg:         #f4f6fa;
  --card:       #ffffff;
  --border:     #e4e9f2;
  --text:       #1e293b;
  --text-soft:  #64748b;
  --text-light: #94a3b8;
  --success:    #10b981;
  --warning:    #f59e0b;
  --danger:     #ef4444;
  --info:       #3b82f6;
  --sidebar-w:  240px;
  --header-h:   72px;
  --radius:     12px;
  --shadow:     0 1px 4px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.12);
  --transition: .18s ease;
}

html { font-size: 15px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--blue-night);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.5rem 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-logo {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--blue-light), var(--accent));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

.brand-name {
  display: block;
  font-weight: 700;
  font-size: .95rem;
  color: #fff;
  letter-spacing: -.01em;
}

.brand-sub {
  display: block;
  font-size: .7rem;
  color: rgba(255,255,255,.45);
  margin-top: .05rem;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1.25rem;
  color: rgba(255,255,255,.6);
  text-decoration: none;
  font-size: .875rem;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  position: relative;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.9);
}

.nav-item.active {
  background: rgba(255,255,255,.1);
  color: #fff;
}

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

.nav-icon { width: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .62rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
}
.nav-badge.visible { display: flex; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .7rem;
  color: rgba(255,255,255,.4);
}

.status-dot {
  width: 7px; height: 7px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* ============================================================
   MOBILE TOGGLE
   ============================================================ */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 1rem; left: 1rem;
  z-index: 200;
  background: var(--blue-night);
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 42px; height: 42px;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.main-layout {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- HEADER ---- */
.top-header {
  height: var(--header-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 1rem;
}

.header-left { display: flex; align-items: baseline; gap: 1rem; min-width: 0; }

.section-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.header-date {
  font-size: .8rem;
  color: var(--text-light);
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: .625rem;
  flex-shrink: 0;
}

/* ---- MAIN CONTENT ---- */
.main-content { flex: 1; padding: 2rem; }

/* ---- SECTIONS ---- */
.section { display: none; }
.section.active { display: block; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border: none;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1;
}

.btn-primary {
  background: var(--blue-mid);
  color: #fff;
}
.btn-primary:hover { background: var(--blue-night); transform: translateY(-1px); }

.btn-secondary {
  background: var(--accent-soft);
  color: var(--accent);
}
.btn-secondary:hover { background: #ddd6fe; }

.btn-outline {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--blue-light); color: var(--blue-light); }

.btn-danger {
  background: #fee2e2;
  color: var(--danger);
}
.btn-danger:hover { background: #fecaca; }

.btn-sm {
  padding: .35rem .75rem;
  font-size: .75rem;
}

.btn-success-sm {
  background: #d1fae5;
  color: var(--success);
  padding: .35rem .75rem;
  font-size: .75rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: background var(--transition);
}
.btn-success-sm:hover { background: #a7f3d0; }

.btn-ghost-sm {
  background: transparent;
  color: var(--text-soft);
  padding: .35rem .75rem;
  font-size: .75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-weight: 600;
  transition: all var(--transition);
}
.btn-ghost-sm:hover { border-color: var(--danger); color: var(--danger); }

.btn-todo-sm {
  background: transparent;
  color: var(--text-soft);
  padding: .35rem .75rem;
  font-size: .75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-weight: 600;
  transition: all var(--transition);
}
.btn-todo-sm:hover { border-color: var(--blue-light); color: var(--blue-light); }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

/* ============================================================
   KPI GRID
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .375rem;
  transition: transform var(--transition), box-shadow var(--transition);
}

.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.kpi-label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.kpi-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.kpi-sub {
  font-size: .72rem;
  color: var(--text-light);
}

.kpi-card.kpi-accent { border-top: 3px solid var(--accent); }
.kpi-card.kpi-success { border-top: 3px solid var(--success); }
.kpi-card.kpi-warning { border-top: 3px solid var(--warning); }
.kpi-card.kpi-danger  { border-top: 3px solid var(--danger); }
.kpi-card.kpi-info    { border-top: 3px solid var(--info); }
.kpi-card.kpi-blue    { border-top: 3px solid var(--blue-light); }

/* ============================================================
   OVERVIEW ROW
   ============================================================ */
.overview-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

/* ============================================================
   REVENUE CHART
   ============================================================ */
.chart-card { margin-bottom: 0; }

.chart-wrapper {
  padding: 2rem 1.5rem 1rem;
  display: flex;
  align-items: flex-end;
  gap: .75rem;
  min-height: 200px;
}

.chart-bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .375rem;
  flex: 1;
}

.chart-bar-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  height: 160px;
  align-items: flex-end;
}

.chart-bar {
  width: 60%;
  background: linear-gradient(180deg, var(--blue-light), var(--blue-mid));
  border-radius: 4px 4px 0 0;
  position: relative;
  min-height: 4px;
  transition: height .4s ease;
}

.chart-bar:hover { background: linear-gradient(180deg, var(--accent), var(--blue-mid)); }

.chart-bar-val {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: .65rem;
  font-weight: 700;
  color: var(--text-soft);
  white-space: nowrap;
}

.chart-label {
  font-size: .72rem;
  color: var(--text-light);
  font-weight: 600;
}

/* ============================================================
   PIPELINE
   ============================================================ */
.pipeline-card { margin-bottom: 0; }

.pipeline-col-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: 1rem 1.5rem 1.5rem;
}

.pipeline-col {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.pipeline-col-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-soft);
  width: 110px;
  flex-shrink: 0;
}

.pipeline-bar-outer {
  flex: 1;
  height: 20px;
  background: var(--bg);
  border-radius: 10px;
  overflow: hidden;
}

.pipeline-bar-inner {
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--blue-light), var(--accent));
  transition: width .4s ease;
}

.pipeline-col-count {
  font-size: .78rem;
  font-weight: 700;
  color: var(--text);
  width: 28px;
  text-align: right;
}

/* ============================================================
   ACTIVITY
   ============================================================ */
.activity-card { margin-bottom: 0; }

.activity-list {
  padding: .5rem 1.5rem 1rem;
  max-height: 320px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  gap: .875rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--blue-light);
  margin-top: .45rem;
  flex-shrink: 0;
}

.activity-dot.dot-success { background: var(--success); }
.activity-dot.dot-warning { background: var(--warning); }
.activity-dot.dot-danger  { background: var(--danger); }
.activity-dot.dot-accent  { background: var(--accent); }

.activity-text {
  font-size: .82rem;
  color: var(--text);
  flex: 1;
}

.activity-time {
  font-size: .72rem;
  color: var(--text-light);
  white-space: nowrap;
}

/* ============================================================
   RECOMMENDATIONS
   ============================================================ */
.reco-card { margin-bottom: 0; }

.reco-item {
  display: flex;
  gap: .875rem;
  padding: .875rem 1.5rem;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.reco-item:last-child { border-bottom: none; }

.reco-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  margin-top: .1rem;
}

.reco-text {
  font-size: .82rem;
  color: var(--text);
  line-height: 1.55;
}

.reco-note {
  font-size: .72rem;
  color: var(--text-soft);
  margin-top: .2rem;
  font-style: italic;
}

/* ============================================================
   PRIORITY ACTIONS
   ============================================================ */
.priority-action-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.priority-action-item:last-child { border-bottom: none; }
.priority-action-item.done-action { opacity: .5; }

.action-priority { flex-shrink: 0; }
.action-info { flex: 1; min-width: 200px; }
.action-title { font-size: .88rem; font-weight: 600; color: var(--text); }
.action-meta { font-size: .75rem; color: var(--text-soft); margin-top: .15rem; }
.action-tags {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .65rem;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: .02em;
}

.badge-nouveau    { background: #eff6ff; color: #2563eb; }
.badge-contacte   { background: #f0fdf4; color: #16a34a; }
.badge-qualifie   { background: #fefce8; color: #ca8a04; }
.badge-devis      { background: #faf5ff; color: #9333ea; }
.badge-relancer   { background: #fff7ed; color: #ea580c; }
.badge-gagne      { background: #dcfce7; color: #15803d; }
.badge-perdu      { background: #fee2e2; color: #dc2626; }

.badge-brouillon  { background: #f1f5f9; color: #475569; }
.badge-envoye     { background: #eff6ff; color: #2563eb; }
.badge-negociation{ background: #faf5ff; color: #7c3aed; }

.badge-actif      { background: #d1fae5; color: #065f46; }
.badge-dormant    { background: #f3f4f6; color: #4b5563; }
.badge-fideliser  { background: #fef3c7; color: #92400e; }

.badge-enretard   { background: #fee2e2; color: #dc2626; }
.badge-relancee   { background: #fff7ed; color: #ea580c; }
.badge-payee      { background: #d1fae5; color: #065f46; }

.badge-elevee     { background: #fee2e2; color: #dc2626; }
.badge-moyenne    { background: #fef3c7; color: #92400e; }
.badge-faible     { background: #f0fdf4; color: #16a34a; }

.badge-info { background: #eff6ff; color: #2563eb; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #dc2626; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}

.data-table th {
  background: var(--bg);
  color: var(--text-soft);
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .875rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

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

.data-table tr:hover td { background: #fafbff; }

.td-name { font-weight: 600; }
.td-company { color: var(--text-soft); }
.td-amount { font-weight: 700; color: var(--blue-mid); }
.td-muted { color: var(--text-soft); font-size: .78rem; }

.actions-cell { display: flex; gap: .375rem; align-items: center; flex-wrap: nowrap; }

/* ============================================================
   FILTERS
   ============================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.filter-input, .filter-select {
  padding: .45rem .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .82rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color var(--transition);
}

.filter-input:focus, .filter-select:focus { border-color: var(--blue-light); }
.filter-input { min-width: 180px; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: .375rem;
  font-size: .82rem;
  color: var(--text-soft);
  cursor: pointer;
  white-space: nowrap;
}

/* ============================================================
   INVOICE TOTAL BAR
   ============================================================ */
.invoice-total-bar {
  font-size: .88rem;
  color: var(--text-soft);
}

.invoice-total-bar strong {
  color: var(--danger);
  font-size: 1rem;
}

/* ============================================================
   LEAD SOURCES
   ============================================================ */
#leadSourcesGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  padding: 1.5rem;
}

.source-card {
  background: var(--bg);
  border-radius: 10px;
  padding: 1.25rem;
  border: 1px solid var(--border);
}

.source-name {
  font-weight: 700;
  font-size: .9rem;
  margin-bottom: .75rem;
  color: var(--text);
}

.source-stat {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  color: var(--text-soft);
  padding: .2rem 0;
}

.source-stat strong { color: var(--text); font-weight: 700; }

.source-conversion {
  margin-top: .625rem;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.source-conversion-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #34d399);
  border-radius: 3px;
  transition: width .4s ease;
}

.sources-insight {
  padding: 1rem 1.5rem 1.5rem;
  font-size: .85rem;
  color: var(--text-soft);
  font-style: italic;
  border-top: 1px solid var(--border);
}

/* ============================================================
   SETTINGS
   ============================================================ */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.settings-block {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.settings-block:last-child { border-bottom: none; }

.settings-subtitle {
  font-size: .88rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .5rem;
}

.settings-desc {
  font-size: .82rem;
  color: var(--text-soft);
  line-height: 1.6;
  margin-bottom: .875rem;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .625rem;
}

.danger-block { background: #fff5f5; }

.connectable-list {
  padding: .5rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .875rem;
}

.connectable-item {
  display: flex;
  gap: .875rem;
  align-items: flex-start;
}

.connectable-icon { font-size: 1.3rem; flex-shrink: 0; margin-top: .1rem; }

.connectable-item strong {
  display: block;
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .15rem;
}

.connectable-item p {
  font-size: .78rem;
  color: var(--text-soft);
  line-height: 1.5;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  z-index: 300;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
  padding: 1rem;
}

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

.modal {
  background: var(--card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: fadeIn .2s ease;
}

.modal-sm { max-width: 380px; }

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

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

.modal-header h2 { font-size: 1.05rem; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-soft);
  padding: .2rem .4rem;
  border-radius: 6px;
  transition: background var(--transition);
}
.modal-close:hover { background: var(--bg); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .625rem;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* ============================================================
   FORMS
   ============================================================ */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1.5rem;
}

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

.form-group label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-soft);
}

.required { color: var(--danger); }

.form-group input, .form-group select {
  padding: .575rem .875rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .875rem;
  color: var(--text);
  background: var(--card);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus, .form-group select:focus {
  border-color: var(--blue-light);
  box-shadow: 0 0 0 3px rgba(79,121,200,.12);
}

.form-message {
  margin: 0 1.5rem;
  padding: .625rem .875rem;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 600;
  display: none;
}

.form-message.error   { background: #fee2e2; color: var(--danger); display: block; }
.form-message.success { background: #d1fae5; color: var(--success); display: block; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--blue-night);
  color: #fff;
  padding: .875rem 1.375rem;
  border-radius: 10px;
  font-size: .85rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 500;
  opacity: 0;
  transform: translateY(12px);
  transition: all .25s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success { background: #065f46; }
.toast.error   { background: #991b1b; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-light);
  font-size: .9rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
  .settings-grid { grid-template-columns: 1fr; }
  .overview-row  { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    width: 240px;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .mobile-toggle { display: flex; align-items: center; justify-content: center; }

  .main-layout { margin-left: 0; }

  .top-header {
    padding: 0 1rem 0 4rem;
    flex-wrap: wrap;
    height: auto;
    padding-top: .75rem;
    padding-bottom: .75rem;
    gap: .75rem;
  }

  .header-actions {
    flex-wrap: wrap;
    gap: .4rem;
  }

  .main-content { padding: 1rem; }

  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 540px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-full { grid-column: auto; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-input, .filter-select { width: 100%; }
  .top-header { padding-left: 4rem; }
  .header-actions .btn { padding: .45rem .75rem; font-size: .77rem; }
  #leadSourcesGrid { grid-template-columns: 1fr; }
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
#login-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--blue-night) 0%, #0f1a3a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

body.authenticated #login-screen { display: none; }

body:not(.authenticated) .sidebar,
body:not(.authenticated) #mainLayout,
body:not(.authenticated) .mobile-toggle { display: none !important; }

.login-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  margin-bottom: .5rem;
}

.login-logo {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--blue-light), var(--accent));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 700; color: #fff;
}

.login-brand-name {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--blue-night);
  letter-spacing: -.02em;
}

.login-sub {
  color: var(--text-soft);
  font-size: .85rem;
  margin-bottom: 2rem;
}

.login-label {
  display: block;
  text-align: left;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: .4rem;
}

.login-input {
  width: 100%;
  padding: .65rem .875rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  letter-spacing: .08em;
}

.login-input:focus {
  border-color: var(--blue-light);
  box-shadow: 0 0 0 3px rgba(79,121,200,.12);
}

.login-submit {
  width: 100%;
  margin-top: 1rem;
  padding: .75rem;
  font-size: .95rem;
}

.login-hint {
  margin-top: 1.25rem;
  font-size: .78rem;
  color: var(--text-light);
}

.login-hint code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .1rem .4rem;
  font-size: .78rem;
  color: var(--blue-mid);
  font-family: monospace;
}

/* Password toggle wrapper */
.pwd-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.pwd-wrapper .login-input,
.pwd-wrapper input {
  width: 100%;
  padding-right: 2.6rem;
}

.pwd-toggle {
  position: absolute;
  right: .55rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: .25rem;
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color var(--transition);
  line-height: 0;
}

.pwd-toggle:hover { color: var(--text-soft); }
.pwd-toggle svg, .pwd-toggle svg * { pointer-events: none; }

/* Logout button */
.logout-btn {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  padding: .6rem 1.25rem;
  background: transparent;
  border: none;
  border-top: 1px solid rgba(255,255,255,.08);
  color: rgba(255,255,255,.45);
  font-size: .8rem;
  cursor: pointer;
  margin-top: .5rem;
  transition: color var(--transition), background var(--transition);
  text-align: left;
}

.logout-btn:hover {
  color: rgba(255,255,255,.85);
  background: rgba(255,255,255,.06);
}

/* ── Autocomplete client (modal devis) ── */
.autocomplete-wrapper {
  position: relative;
}

.autocomplete-list {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  list-style: none;
  margin: 0;
  padding: .25rem 0;
  z-index: 9999;
  max-height: 220px;
  overflow-y: auto;
}

.autocomplete-list.open {
  display: block;
}

.autocomplete-list li {
  padding: .55rem 1rem;
  cursor: pointer;
  font-size: .875rem;
  color: var(--text);
  transition: background var(--transition);
}

.autocomplete-list li:hover,
.autocomplete-list li.active {
  background: #eef2ff;
  color: var(--blue-mid);
}

.autocomplete-list li .ac-match {
  font-weight: 600;
}
