:root {
  --navy: #011d33;        /* Bleu nuit */
  --navy-2: #12354d;      /* Bleu secondaire */
  --accent: #12354d;
  --accent-soft: #e6edf3;
  --green: #26c55e;       /* aConnect B2B */
  --green-dark: #126b36;
  --bg: #f3f6f9;
  --card: #fdfdfe;        /* Blanc */
  --text: #011d33;
  --muted: #55697b;
  --line: #c8d6e2;        /* Bleu gris clair */
  --hot: #d6402b;   --hot-bg: #fdecea;
  --warm: #c77700;  --warm-bg: #fff4e0;
  --cold: #3c6fa8;  --cold-bg: #e8f0fa;
  --ok: #1d8a4e;    --ok-bg: #e6f5ec;
  --rec: #e0322b;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.4;
  padding-bottom: calc(76px + var(--safe-b));
  min-height: 100dvh;
}
.hidden { display: none !important; }

/* ---------- Barre du haut ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--navy); color: #fff;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 17px; }
.brand img { height: 40px; margin: -8px -6px; width: auto; display: block; }
.brand .sep { width: 1px; height: 20px; background: rgba(253,253,254,.3); }
.brand #topTitle { font-weight: 500; font-size: 15px; color: #c8d6e2; }
.login-logo { display: block; margin: 0 auto 18px; background: var(--navy); border-radius: 18px; padding: 18px 26px; width: 180px; }
.login-logo img { width: 100%; display: block; }
.net { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: rgba(255,255,255,.12); }
.net.off { background: #f3b23a; color: #3a2700; font-weight: 600; }
.outbox { background: #fff7e0; color: #5c4300; font-size: 14px; padding: 9px 16px; border-bottom: 1px solid #f0dfaa; display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.outbox button { font-size: 13px; padding: 5px 10px; }

main { max-width: 640px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 4px 0 14px; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 0 10px; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Onglets du bas ---------- */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: #fff; border-top: 1px solid var(--line);
  display: flex; padding-bottom: var(--safe-b);
}
.tabs a { flex: 1; text-align: center; padding: 8px 0 9px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.tabs a.active { color: var(--navy); }
.tabs a.active svg { stroke: var(--green); }
body:not(.is-admin) .admin-only { display: none; }

/* ---------- Cartes / formulaires ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 2px rgba(16,32,44,.06); border: 1px solid var(--line); }
.card + .card { margin-top: 12px; }
label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin: 10px 0 4px; }
input, textarea, select {
  width: 100%; font: inherit; font-size: 16px; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: #fff;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--green); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 84px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
@media (max-width: 360px) { .grid2 { grid-template-columns: 1fr; } }

button, .btn {
  font: inherit; font-weight: 650; font-size: 15px; border: 0; border-radius: 11px; cursor: pointer;
  padding: 12px 16px; background: var(--accent-soft); color: var(--accent); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
button:disabled { opacity: .5; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-dark { background: var(--navy); color: #fff; }
.btn-danger { background: var(--hot-bg); color: var(--hot); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-block { width: 100%; }
.btn-big { padding: 16px; font-size: 17px; border-radius: 14px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1; }

/* ---------- Choix de la source du contact ---------- */
.sources { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.source {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); color: var(--navy);
  padding: 14px 6px; display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; line-height: 1.2; text-align: center;
}
.source svg { width: 30px; height: 30px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.source.done { border-color: var(--green); background: #e8f9ee; }
.source svg { stroke: var(--navy-2); }
.alt-link { display: block; text-align: center; margin-top: 10px; font-size: 14px; color: var(--navy-2); background: none; width: 100%; padding: 6px; font-weight: 600; }
.card-preview { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.card-preview img { width: 92px; height: 58px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.status-line { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Services ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { text-align: left; padding: 9px 13px; border-radius: 99px; background: #fff; border: 1px solid var(--line); color: var(--text); font-weight: 550; font-size: 14px; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip[data-pole] { border-left: 4px solid var(--pole); }
.chip[data-pole].on { background: var(--pole-bg); border-color: var(--pole); color: var(--pole-dark); }
[data-pole="b2b"] { --pole: #26c55e; --pole-bg: #e8f9ee; --pole-dark: #126b36; }
[data-pole="voice"] { --pole: #00c2e8; --pole-bg: #e5f9fd; --pole-dark: #007f99; }
[data-pole="flow"] { --pole: #a855f7; --pole-bg: #f3eafe; --pole-dark: #7135b3; }
[data-pole="data"] { --pole: #f5a623; --pole-bg: #fff3dd; --pole-dark: #9a5b00; }
.svc-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.svc-tag { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 6px; background: var(--pole-bg, #eef2f6); color: var(--pole-dark, var(--muted)); }

/* ---------- Dictaphone ---------- */
.recorder { text-align: center; padding: 22px 16px 18px; }
.mic {
  width: 104px; height: 104px; border-radius: 50%; background: var(--green); color: #fff;
  display: inline-grid; place-items: center; box-shadow: 0 6px 18px rgba(38,197,94,.38); padding: 0;
}
.mic.recording { background: var(--rec); }
.mic svg { width: 44px; height: 44px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; }
.mic.recording { animation: pulse 1.4s ease-in-out infinite; }
.mic.recording .stop { width: 34px; height: 34px; border-radius: 6px; background: #fff; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(224,50,43,.45); } 50% { box-shadow: 0 0 0 18px rgba(224,50,43,0); } }
.timer { font-variant-numeric: tabular-nums; font-size: 26px; font-weight: 700; margin-top: 10px; }
.rec-hint { color: var(--muted); font-size: 14px; margin-top: 8px; }
.recorded { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.recorded audio { width: 100%; }

.save-bar { position: sticky; bottom: calc(64px + var(--safe-b)); padding: 18px 0 8px; margin-top: 16px; background: linear-gradient(transparent, var(--bg) 30%); }

/* ---------- Liste ---------- */
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: none; }
.filters .chip { flex: none; }
.lead-item { display: block; color: inherit; text-decoration: none; }
.lead-item .top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.lead-item .name { font-weight: 700; font-size: 16px; }
.lead-item .company { color: var(--muted); font-size: 14px; }
.lead-item .sum { font-size: 14px; color: #36424f; margin-top: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lead-item .meta { font-size: 12px; color: var(--muted); margin-top: 8px; display: flex; gap: 10px; flex-wrap: wrap; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 99px; white-space: nowrap; }
.b-chaud { background: var(--hot-bg); color: var(--hot); }
.b-tiede { background: var(--warm-bg); color: var(--warm); }
.b-froid { background: var(--cold-bg); color: var(--cold); }
.b-action { background: var(--navy); color: #fff; }
.b-pending { background: #fff4d6; color: #7a5600; }
.b-error { background: var(--hot-bg); color: var(--hot); }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* ---------- Fiche ---------- */
.lead-head h1 { margin-bottom: 2px; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.quick .btn { flex-direction: column; font-size: 12px; padding: 10px 4px; gap: 4px; }
.quick svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.action-box { background: var(--navy); color: #fff; border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; }
.action-box .lbl { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; opacity: .75; font-weight: 700; }
.action-box .btn { margin-top: 10px; background: #fff; color: var(--navy); }
.field { padding: 10px 0; border-bottom: 1px solid var(--line); }
.field:last-child { border-bottom: 0; }
.field .k { font-size: 12px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .03em; }
.field .v { margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
details summary { cursor: pointer; font-weight: 650; color: var(--accent); padding: 4px 0; }

/* ---------- Scanner QR ---------- */
.scanner { position: fixed; inset: 0; z-index: 50; background: #000; display: flex; flex-direction: column; }
.scanner video { flex: 1; width: 100%; object-fit: cover; }
.scanner .frame { position: absolute; top: 50%; left: 50%; width: 64vw; max-width: 300px; aspect-ratio: 1; transform: translate(-50%, -58%); border: 3px solid #fff; border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
.scanner .bar { padding: 16px 16px calc(16px + var(--safe-b)); background: #000; color: #fff; text-align: center; }
.scanner .bar p { margin: 0 0 12px; }

/* ---------- Divers ---------- */
.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--text); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 15px; opacity: 0; pointer-events: none; transition: .25s; z-index: 60; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.login-wrap { max-width: 380px; margin: 8vh auto 0; }
.err { color: var(--hot); font-size: 14px; margin-top: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
td button { white-space: nowrap; }
td, th { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 24px; }
.stat span { font-size: 12px; color: var(--muted); }
