/* ===== Atelier CRM — thème sombre orange (inspiré Signd) ===== */
:root {
  --bg: #0c111c;
  --bg-panel: #10192a;
  --bg-card: #161f31;
  --bg-card-hover: #1b2539;
  --bg-input: #1a2438;
  --border: #223049;
  --border-soft: #1b2740;
  --text: #e8edf5;
  --text-dim: #8b97ab;
  --text-faint: #5d6a80;
  --accent: #e8722a;
  --accent-soft: rgba(232, 114, 42, 0.14);
  --danger: #e05252;
  --radius: 12px;
  --sidebar-w: 220px;
}

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

[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; min-height: 100dvh; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.brand-logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #f08c3a, #e05e1e);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 17px; color: #fff;
  flex-shrink: 0;
}
.brand-logo.small { width: 28px; height: 28px; font-size: 14px; border-radius: 7px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 14px; }
.brand-text span { font-size: 9px; letter-spacing: 0.8px; color: var(--text-faint); }

.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: none; border-radius: 9px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item svg { width: 17px; height: 17px; fill: currentColor; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-card); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }

.sidebar-footer { margin-top: auto; padding: 14px 16px; border-top: 1px solid var(--border-soft); }

.storage-badge {
  font-size: 10px; font-weight: 700; letter-spacing: 0.6px;
  padding: 4px 9px; border-radius: 20px;
  background: var(--bg-card); color: var(--text-dim);
  text-transform: uppercase;
}
.storage-badge.cloud { background: rgba(76, 175, 80, 0.15); color: #6fce74; }

/* ===== Mobile bars ===== */
.mobile-bar { display: none; }
.bottom-nav { display: none; }

/* ===== Main ===== */
.main { flex: 1; padding: 28px 32px; min-width: 0; }

.page-title {
  font-size: 22px; font-weight: 700;
  padding-left: 12px; margin-bottom: 20px;
  position: relative;
}
.page-title::before {
  content: ""; position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 4px; border-radius: 3px; background: var(--accent);
}

.muted { color: var(--text-faint); }

/* ===== Pipeline ===== */
.pipeline-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.pipeline-tools { display: flex; gap: 10px; margin-bottom: 20px; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 12px; min-width: 220px;
}
.search-box svg { width: 15px; height: 15px; color: var(--text-faint); }
.search-box input {
  background: transparent; border: none; outline: none;
  color: var(--text); font-size: 13px; width: 100%;
}
.search-box input::placeholder { color: var(--text-faint); }

.board {
  display: flex; gap: 14px;
  overflow-x: auto;
  padding-bottom: 16px;
  align-items: flex-start;
  -webkit-overflow-scrolling: touch;
  scrollbar-color: var(--border) transparent;
}
.board::-webkit-scrollbar { height: 8px; }
.board::-webkit-scrollbar-track { background: transparent; }
.board::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
.column-body::-webkit-scrollbar { width: 6px; }
.column-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

.column {
  background: rgba(16, 25, 42, 0.6);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  min-width: 260px; width: 260px;
  flex-shrink: 0;
  display: flex; flex-direction: column;
  max-height: calc(100dvh - 190px);
}
.column.drop-target { border-color: var(--accent); background: var(--accent-soft); }

.column-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  color: var(--text-dim); text-transform: uppercase;
}
.column-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.column-count {
  margin-left: auto;
  background: var(--bg-card); border-radius: 20px;
  min-width: 22px; height: 20px; padding: 0 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text-dim);
}

.column-body {
  padding: 4px 8px 10px;
  display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto;
  min-height: 60px;
}

/* ===== Lead card ===== */
.lead-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  padding: 12px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.lead-card:hover { background: var(--bg-card-hover); border-color: var(--border); }
.lead-card.dragging-source { opacity: 0.35; }

.lead-top { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.lead-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #3a2a1c, #4d3016);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}
.lead-name { font-weight: 600; font-size: 13.5px; word-break: break-word; }
.lead-sub { font-size: 11.5px; color: var(--text-faint); }

.lead-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 7px; }
.chip {
  font-size: 10.5px; font-weight: 600;
  padding: 3px 8px; border-radius: 20px;
  background: var(--bg-input); color: var(--text-dim);
  white-space: nowrap;
}
.chip.etat-green { background: rgba(76, 175, 80, 0.16); color: #6fce74; }
.chip.etat-orange { background: rgba(232, 114, 42, 0.16); color: #f0924d; }
.chip.etat-red { background: rgba(224, 82, 82, 0.16); color: #ee7a7a; }
.chip.etat-blue { background: rgba(77, 163, 255, 0.16); color: #7db8f5; }
.chip.etat-gray { background: rgba(139, 151, 171, 0.12); color: var(--text-dim); }

.lead-note {
  font-size: 12px; color: var(--text-dim);
  line-height: 1.4;
  margin-bottom: 7px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.lead-links { display: flex; gap: 10px; align-items: center; }
.lead-links a {
  font-size: 11.5px; color: var(--accent); text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
}
.lead-links a:hover { text-decoration: underline; }

/* Ghost qui suit le doigt / la souris */
.drag-ghost {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  width: 244px;
  transform: rotate(2deg) scale(1.03);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
  opacity: 0.95;
}

/* ===== Formulaires ===== */
.card {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 560px;
}
.paste-card { margin-bottom: 16px; }

.field-label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.hint { font-size: 11.5px; color: var(--text-faint); margin-bottom: 10px; line-height: 1.5; }

input[type="text"], input[type="tel"], input[type="search"], textarea, select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; }
select { appearance: none; -webkit-appearance: none; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.field.span2, .span2 { grid-column: span 2; }

.btn-primary {
  margin-top: 18px;
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, #ef8434, #dd5f1c);
  border: none; border-radius: 10px;
  color: #fff; font-size: 14px; font-weight: 600;
  padding: 12px;
  cursor: pointer;
  transition: filter 0.15s;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-primary svg { width: 16px; height: 16px; fill: currentColor; }

.btn-danger {
  background: rgba(224, 82, 82, 0.12);
  border: 1px solid rgba(224, 82, 82, 0.3);
  color: #ee7a7a;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
}
.btn-danger:hover { background: rgba(224, 82, 82, 0.2); }

/* Aperçu multi-lignes collées */
.multi-preview { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.multi-preview .preview-row {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 12.5px;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.multi-preview .preview-row strong { color: var(--text); }
.multi-preview .preview-row span { color: var(--text-faint); }

/* ===== Dashboard ===== */
.dash-section {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
  max-width: 860px;
}
.dash-section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 12px;
}
.count-pill {
  background: var(--bg-card);
  border-radius: 20px;
  min-width: 22px; height: 19px; padding: 0 7px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px;
}

.objectif-card { text-align: center; }
.objectif-card .dash-section-title { justify-content: center; }
.rings { display: flex; justify-content: center; gap: 46px; padding: 8px 0 4px; flex-wrap: wrap; }
.ring { position: relative; width: 110px; }
.ring svg { width: 76px; height: 76px; }
.ring-num {
  position: absolute; top: 24px; left: 50%; transform: translateX(-50%);
  text-align: center; font-size: 20px; font-weight: 700;
  pointer-events: none;
}
.ring-label { font-size: 11px; color: var(--text-dim); margin-top: 6px; line-height: 1.35; }
.objectif-note { font-size: 11.5px; color: var(--text-faint); margin-top: 10px; }

.alert-banner {
  display: flex; align-items: center; gap: 13px;
  background: rgba(224, 82, 82, 0.1);
  border: 1px solid rgba(224, 82, 82, 0.28);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 14px;
  max-width: 860px;
}
.alert-banner strong { color: #f08a8a; font-size: 13.5px; }
.alert-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.alert-icon { font-size: 20px; }

.dash-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  padding: 11px 13px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.dash-row:hover { background: var(--bg-card-hover); }
.dash-row:last-child { margin-bottom: 0; }
.dash-row-info { flex: 1; min-width: 0; }
.dash-row-name { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dash-row-name .late { font-size: 11px; font-weight: 600; color: #ee7a7a; }
.dash-row-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--text-faint);
  margin-top: 4px;
}
.dash-row-meta a { color: var(--accent); text-decoration: none; }
.dash-row-meta .chip { font-size: 10px; padding: 2px 7px; }

.row-action {
  display: inline-flex; align-items: center; gap: 5px;
  background: linear-gradient(135deg, #ef8434, #dd5f1c);
  border: none; border-radius: 20px;
  color: #fff; font-size: 12px; font-weight: 600;
  padding: 7px 14px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.row-action:hover { filter: brightness(1.1); }

.empty-row {
  text-align: center;
  color: var(--text-faint);
  font-size: 12.5px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: 11px;
}

.funnel-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.funnel-label { width: 90px; font-size: 12px; color: var(--text-dim); text-align: right; flex-shrink: 0; }
.funnel-track { flex: 1; background: var(--bg-input); border-radius: 20px; height: 18px; overflow: hidden; }
.funnel-bar {
  height: 100%;
  background: linear-gradient(90deg, #b35318, #ef8434);
  border-radius: 20px;
  display: flex; align-items: center;
  padding-left: 9px;
  font-size: 10.5px; font-weight: 700; color: #fff;
  min-width: 22px;
  transition: width 0.4s;
}
.funnel-pct { width: 40px; font-size: 11px; color: var(--text-faint); flex-shrink: 0; }
.funnel-note {
  margin-top: 12px;
  background: var(--bg-card);
  border-radius: 9px;
  padding: 10px 13px;
  font-size: 12px; color: var(--text-dim);
  line-height: 1.5;
}
.funnel-note strong { color: var(--accent); }

/* ===== Dashboard stats ===== */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-card .stat-value { font-size: 26px; font-weight: 700; }
.stat-card .stat-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.7px; margin-top: 4px; }

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(5, 8, 14, 0.72);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
  z-index: 500;
}
.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  width: 100%; max-width: 520px;
  max-height: 90dvh;
  overflow-y: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h2 { font-size: 17px; }
.icon-btn {
  background: var(--bg-card); border: none; border-radius: 8px;
  color: var(--text-dim); width: 30px; height: 30px;
  cursor: pointer; font-size: 13px;
}
.icon-btn:hover { color: var(--text); }
.modal-actions { display: flex; gap: 10px; justify-content: space-between; margin-top: 6px; }
.modal-actions .btn-primary { margin-top: 0; width: auto; flex: 1; }

/* ===== Écran de verrouillage ===== */
.lock-backdrop { z-index: 800; }
.lock-modal { max-width: 340px; text-align: center; }
.lock-icon { font-size: 34px; margin-bottom: 10px; }
.lock-modal h2 { font-size: 18px; margin-bottom: 8px; }
.lock-modal .hint { margin-bottom: 14px; }
.lock-modal input { text-align: center; font-size: 15px; letter-spacing: 2px; }
.lock-error { color: #ee7a7a; font-size: 12.5px; margin-top: 9px; }
.lock-modal .btn-primary { margin-top: 14px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 900;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* ===== Mobile ===== */
@media (max-width: 760px) {
  .sidebar { display: none; }

  .mobile-bar {
    display: flex; align-items: center; gap: 10px;
    position: fixed; top: 0; left: 0; right: 0;
    height: 52px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-soft);
    padding: 0 14px;
    z-index: 100;
  }
  .mobile-bar .storage-badge { margin-left: auto; }

  .bottom-nav {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-soft);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    z-index: 100;
  }
  .bottom-nav .nav-item {
    flex: 1;
    flex-direction: column; gap: 3px;
    font-size: 10.5px;
    padding: 7px 4px;
    align-items: center;
  }
  .bottom-nav .nav-item svg { width: 19px; height: 19px; }

  .main { padding: 68px 14px 88px; }

  .column { min-width: 240px; width: 240px; max-height: none; }
  .column-body { max-height: calc(100dvh - 300px); }

  .card { max-width: none; }
  .form-grid { grid-template-columns: 1fr; }
  .field.span2, .span2 { grid-column: span 1; }
  .modal-actions { grid-column: span 1; }
}
