:root {
  --navy: #1f3864;
  --navy-2: #2e5288;
  --ink: #12192b;
  --muted: #6b7280;
  --line: #e5e8ef;
  --bg: #f4f6fa;
  --card: #ffffff;
  --ok: #16794a;
  --warn: #b45309;
  --danger: #b91c1c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy); }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, #e8eefb 0%, transparent 60%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 36px 32px 30px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 26px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .5px;
}

.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--muted); }

h1 { font-size: 24px; margin: 0 0 8px; letter-spacing: -.3px; }
.lead-text { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0 0 22px; }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }

input[type="email"], input[type="text"], input[type="date"], input[type="number"], textarea, select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--navy-2);
  box-shadow: 0 0 0 3px rgba(46, 82, 136, .12);
}

textarea { resize: vertical; min-height: 90px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: var(--navy);
  color: #fff;
  transition: background .15s, transform .05s;
}

.btn:hover { background: #18305a; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn-block { width: 100%; }
.btn-ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn-ghost:hover { background: #f7f9fc; }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 8px; }

.notice {
  margin-top: 14px;
  padding: 11px 13px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.45;
  display: none;
}
.notice.show { display: block; }
.notice-ok { background: #e7f6ee; color: #14603c; }
.notice-err { background: #fdeaea; color: #99201f; }

.footnote { margin-top: 22px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.5; }

/* ---------- app ---------- */
.topbar {
  background: var(--navy);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar .brand-mark { background: rgba(255, 255, 255, .16); }
.topbar-title { font-weight: 600; font-size: 14px; }
.topbar-sub { font-size: 12px; opacity: .75; }

.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.topbar a { color: #fff; opacity: .85; text-decoration: none; }
.topbar a:hover { opacity: 1; }

.container { max-width: 1080px; margin: 0 auto; padding: 24px 20px 80px; }

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.kpi {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.kpi-value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; }
.kpi-value small { font-size: 13px; font-weight: 600; color: var(--muted); }

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip:hover:not(.active) { border-color: #c9d2e3; }

.list { display: grid; gap: 10px; }

.lead {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  cursor: pointer;
  border-left: 4px solid transparent;
  transition: transform .08s, box-shadow .15s;
}

.lead:hover { box-shadow: 0 2px 4px rgba(16,24,40,.06), 0 10px 28px rgba(16,24,40,.10); }
.lead:active { transform: scale(.997); }

.lead-name { font-weight: 700; font-size: 15.5px; }
.lead-vehicle { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.lead-meta { color: #98a0ae; font-size: 12px; margin-top: 8px; display: flex; gap: 12px; flex-wrap: wrap; }

.lead-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.lead-amount { font-weight: 700; font-size: 15px; }

.badge {
  display: inline-block;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.b-neuf { background: #fff4d6; color: #8a5c00; }
.b-rappel { background: #fde8e0; color: #a2401d; }
.b-contacte { background: #e3eefb; color: #1f4e8c; }
.b-rdv { background: #e2f4e6; color: #1d6a38; }
.b-offre { background: #ece7f8; color: #553a9c; }
.b-vendu { background: #d6f2e0; color: #0f6b3b; }
.b-perdu { background: #f0f1f3; color: #5b6270; }
.b-injoignable { background: #f0f1f3; color: #5b6270; }

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(12, 18, 32, .45);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 0;
}

.modal.open { display: flex; }

.modal-panel {
  background: #fff;
  width: 100%;
  max-width: 620px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 18px 18px 0 0;
  padding: 24px;
}

@media (min-width: 700px) {
  .modal { align-items: center; padding: 24px; }
  .modal-panel { border-radius: 18px; }
}

.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.modal-title { font-size: 19px; font-weight: 700; }
.modal-close { background: none; border: 0; font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }

.field { margin-bottom: 14px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.detail-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 6px 14px;
  font-size: 14px;
  margin-bottom: 18px;
  padding: 14px 16px;
  background: #f7f9fc;
  border-radius: 12px;
}

.detail-grid dt { color: var(--muted); font-size: 13px; }
.detail-grid dd { margin: 0; }

.section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin: 22px 0 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.commission-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f2f6ff;
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 6px;
}

.commission-box .label { font-size: 13px; color: #33507e; font-weight: 600; }
.commission-box .value { font-size: 20px; font-weight: 700; color: var(--navy); }

.actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.actions .btn { flex: 1 1 auto; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  background: #12192b;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 80;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #99201f; }

.loading { text-align: center; padding: 60px; color: var(--muted); }

@media (max-width: 620px) {
  .lead { grid-template-columns: 1fr; }
  .lead-right { flex-direction: row; align-items: center; justify-content: space-between; }
  .container { padding: 18px 14px 90px; }
  .detail-grid { grid-template-columns: 100px 1fr; }
}
