/* ==========================================================================
   Machine de prospection IDF — Data-Dense Dashboard
   Design system (ui-ux-pro-max): navy #0F172A · accent #0369A1 · slate
   Typo: Fira Sans (UI) + Fira Code (données/chiffres)
   ========================================================================== */
:root {
  --primary: #0f172a;
  --secondary: #334155;
  --accent: #0369a1;
  --accent-hover: #075985;
  --accent-soft: #e0f2fe;
  --bg: #f8fafc;
  --surface: #ffffff;
  --ink: #020617;
  --ink-soft: #64748b;
  --muted: #e8ecf1;
  --border: #e2e8f0;
  --danger: #dc2626;
  --ok: #15803d;      --ok-bg: #dcfce7;
  --warn: #b45309;    --warn-bg: #fef3c7;
  --neutral: #64748b; --neutral-bg: #f1f5f9;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(2, 6, 23, 0.08);
  --mono: "Fira Code", "Cascadia Mono", Consolas, monospace;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }

body {
  font-family: "Fira Sans", system-ui, sans-serif;
  font-size: 14px; line-height: 1.5;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
.container { max-width: 1280px; margin: 0 auto; padding: 0 16px; }

/* --- Topbar --------------------------------------------------------------- */
.topbar { background: var(--primary); color: #fff; padding: 12px 0; position: sticky; top: 0; z-index: 50; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.topbar h1 { font-size: 1.05rem; font-weight: 600; letter-spacing: 0.01em; }
.topbar h1 span { color: #38bdf8; }
.topbar .meta { font-size: 0.75rem; color: #94a3b8; }
.tabs { display: flex; gap: 4px; }
.tab {
  background: transparent; color: #cbd5e1; border: 1px solid transparent;
  padding: 7px 14px; border-radius: 6px; font-weight: 500; font-size: 0.85rem;
  cursor: pointer; font-family: inherit; transition: background 0.15s, color 0.15s;
}
.tab:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.tab.active { background: var(--accent); color: #fff; }
.tab-count { font-family: var(--mono); background: rgba(255,255,255,0.18); border-radius: 4px; padding: 1px 6px; font-size: 0.72rem; margin-left: 5px; }
.tab-pane { display: none; padding-top: 18px; }
.tab-pane.active { display: block; }

/* --- Boutons / champs ------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px;
  border-radius: 6px; font-weight: 500; font-size: 0.85rem; text-decoration: none;
  border: 1px solid transparent; cursor: pointer; font-family: inherit;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--surface); color: var(--secondary); border-color: var(--border); }
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); }
.icon { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
select, input[type="search"], input[type="text"], input[type="tel"], input[type="number"], textarea {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); font-size: 0.85rem; color: var(--ink); font-family: inherit;
  transition: border-color 0.15s;
}
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.12); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* --- KPI cards ------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); border-left: 3px solid var(--accent); }
.stat .num { font-family: var(--mono); font-size: 1.45rem; font-weight: 600; line-height: 1.2; }
.stat .lbl { font-size: 0.72rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px; }

/* --- Cards ------------------------------------------------------------------ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.card-head { padding: 11px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; background: linear-gradient(to bottom, #fdfefe, #f8fafc); }
.card-head h2 { font-size: 0.9rem; font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: 0.04em; }
.card-head .hint { font-size: 0.75rem; color: var(--ink-soft); }
.pad { padding: 12px 16px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.toolbar label { display: inline-flex; flex-direction: column; gap: 3px; font-size: 0.72rem; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.toolbar input[type="search"], .toolbar input[type="text"] { min-width: 200px; }

/* --- Tables denses ----------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
th, td { padding: 8px 12px; text-align: left; vertical-align: top; }
thead th {
  background: var(--muted); border-bottom: 1px solid var(--border);
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--secondary); white-space: nowrap; position: sticky; top: 0; z-index: 1;
  cursor: pointer; user-select: none;
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:nth-child(4n+3):not(.row-detail) { background: #fbfcfd; }
tbody tr.row-main { cursor: pointer; transition: background 0.12s; }
tbody tr.row-main:hover { background: var(--accent-soft); }
tbody tr.row-detail { display: none; background: #f6f9fc; }
tbody tr.row-detail.open { display: table-row; }
.num, .phone, .score, .subscores { font-family: var(--mono); }
.subscores { font-size: 0.7rem; color: var(--ink-soft); white-space: nowrap; }
.score { font-weight: 600; font-size: 0.95rem; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 22px; padding: 4px 2px 8px; }
.detail-grid h4 { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); margin-bottom: 3px; }
.detail-grid p { font-size: 0.83rem; }
.detail-grid a { color: var(--accent); word-break: break-all; }

/* --- Pills ------------------------------------------------------------------- */
.pill { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 0.7rem; font-weight: 600; white-space: nowrap; font-family: var(--mono); }
.pill-A { background: var(--ok-bg); color: var(--ok); }
.pill-B { background: var(--warn-bg); color: var(--warn); }
.pill-C { background: var(--neutral-bg); color: var(--neutral); }
.pill-state { background: #fee2e2; color: var(--danger); font-family: "Fira Sans", sans-serif; }
.pill-state.AUCUN { background: #ede9fe; color: #6d28d9; }
.pill-state.DATE { background: var(--warn-bg); color: var(--warn); }
.pill-state.TEMPLATE { background: var(--accent-soft); color: var(--accent-hover); }

/* --- Mini contrôles ------------------------------------------------------------ */
.mini { font-size: 0.75rem; color: var(--accent); text-decoration: none; font-weight: 600; margin-right: 8px; }
.mini:hover { text-decoration: underline; }
.mini-btn {
  background: var(--surface); color: var(--accent); border: 1px solid var(--accent);
  border-radius: 5px; padding: 4px 10px; font-weight: 600; font-size: 0.75rem;
  cursor: pointer; font-family: inherit; transition: background 0.15s, color 0.15s;
}
.mini-btn:hover { background: var(--accent); color: #fff; }
.mini-input { padding: 5px 8px; border: 1px solid var(--border); border-radius: 5px; font-size: 0.78rem; font-family: var(--mono); min-width: 160px; }
.num-input { width: 54px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 5px; font-size: 0.8rem; font-family: var(--mono); }
.checkline { display: flex; gap: 5px; margin-top: 6px; }
.check-out { margin-top: 4px; max-width: 340px; white-space: normal; font-family: "Fira Sans", sans-serif; }
.weblinks { min-width: 250px; }
.e-notes, .e-statut { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 5px; font-family: inherit; font-size: 0.8rem; }

/* --- Blocs script / aide --------------------------------------------------------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pad ul { padding-left: 16px; font-size: 0.83rem; color: var(--secondary); display: grid; gap: 5px; }
.pad p { font-size: 0.83rem; color: var(--secondary); }
.script-block { background: #f6f9fc; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 6px; padding: 11px 13px; margin-top: 8px; font-size: 0.83rem; color: var(--secondary); }
.script-block strong { display: block; margin-bottom: 3px; color: var(--ink); }

.footer { padding: 18px 0 34px; font-size: 0.73rem; color: var(--ink-soft); }
.spinner {
  display: inline-block; width: 14px; height: 14px; border: 2px solid var(--accent-soft);
  border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite;
  vertical-align: -2px; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 800px) {
  .grid-2 { grid-template-columns: 1fr; }
  .topbar-inner { flex-direction: column; align-items: flex-start; }
  .tabs { width: 100%; overflow-x: auto; }
  .toolbar label { width: 100%; }
  .toolbar input, .toolbar select { width: 100%; }
  .btn { min-height: 44px; }
  .tab { min-height: 42px; }
}

/* ================= v5 — lifting visuel ================= */
body { background: linear-gradient(180deg, #eef2f7 0%, #f8fafc 300px); }
.topbar {
  background: linear-gradient(120deg, #0b1120 0%, #0f172a 55%, #123a5c 100%);
  padding: 16px 0; box-shadow: 0 2px 18px rgba(2, 6, 23, 0.35);
}
.topbar h1 { font-size: 1.2rem; letter-spacing: -0.01em; }
.topbar h1 span { background: linear-gradient(90deg, #38bdf8, #7dd3fc); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tab.active { background: linear-gradient(120deg, #0284c7, #0369a1); box-shadow: 0 2px 10px rgba(3, 105, 161, 0.45); }
.card { border-radius: 12px; box-shadow: 0 2px 5px rgba(2,6,23,0.05), 0 12px 28px -18px rgba(2,6,23,0.18); }
.card-head { background: linear-gradient(to bottom, #ffffff, #f6f9fc); }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-head h2::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: linear-gradient(180deg, #38bdf8, #0369a1); }
.stat { border-left: none; position: relative; overflow: hidden; transition: transform 0.15s, box-shadow 0.15s; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: linear-gradient(180deg, #38bdf8, #0369a1); }
.stat:hover { transform: translateY(-2px); box-shadow: 0 8px 22px -10px rgba(2, 6, 23, 0.25); }
.btn-primary { background: linear-gradient(120deg, #0284c7, #0369a1); box-shadow: 0 2px 8px rgba(3, 105, 161, 0.35); }
.btn-primary:hover { background: linear-gradient(120deg, #0369a1, #075985); }

/* Badges d'état web (analyse auto) */
.webstate {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 11px; border-radius: 999px; font-size: 0.74rem; font-weight: 700;
  letter-spacing: 0.02em;
}
.webstate .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.webstate-wait { background: #f1f5f9; color: #94a3b8; }
.webstate-run  { background: #e0f2fe; color: #0369a1; }
.webstate-AUCUN    { background: #ede9fe; color: #6d28d9; }
.webstate-CASSE    { background: #fee2e2; color: #b91c1c; }
.webstate-DATE     { background: #fef3c7; color: #b45309; }
.webstate-TEMPLATE { background: #cffafe; color: #0e7490; }
.webstate-OK       { background: #dcfce7; color: #15803d; }
.webcell { min-width: 300px; }
.webcell .subscores.wrap { white-space: normal; font-family: "Fira Sans", sans-serif; margin-top: 5px; max-width: 380px; line-height: 1.45; }
.webcell .mini-btn { margin-top: 6px; }
tr.hot-row { background: linear-gradient(90deg, rgba(3, 105, 161, 0.05), transparent 60%) !important; }
tr.hot-row td:first-child { box-shadow: inset 3px 0 0 #0369a1; }
.btn-add.hot { background: linear-gradient(120deg, #0284c7, #0369a1); color: #fff; border-color: transparent; box-shadow: 0 2px 8px rgba(3, 105, 161, 0.35); }
.actioncell { white-space: nowrap; }
.actioncell .mini { display: inline-block; margin: 0 8px 6px 0; }

.opp-toggle { border-bottom: 1px solid var(--border); background: #fbfdff; }
.switch-label { display: flex; align-items: center; gap: 9px; font-size: 0.83rem; color: var(--secondary); font-weight: 500; cursor: pointer; }
.switch-label input { width: 34px; height: 18px; appearance: none; background: #cbd5e1; border-radius: 999px; position: relative; cursor: pointer; transition: background 0.2s; flex-shrink: 0; }
.switch-label input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.switch-label input:checked { background: #0369a1; }
.switch-label input:checked::after { transform: translateX(16px); }
#pager { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
tbody tr.res-row td { padding-top: 12px; padding-bottom: 12px; }
