/* CRM acquisition — styles. Couleurs = palette de référence dataviz (clair + sombre). */
:root {
  color-scheme: light;
  --page: #f9f9f9;
  --surface: #ffffff;
  --surface-2: #f3f3f3;
  --text: #191919;
  --text-2: #666666;
  --grid: #e7e7e7;
  --axis: #c2c2c2;
  --border: rgba(11, 11, 11, 0.10);
  --series: #257de0;
  --series-hover: #1b64be;
  --series-wash: rgba(37, 125, 224, 0.10);
  --good: #006c10;
  --bad: #dc3c3d;
  --warn-bg: #fff6e0;
  --warn-ink: #6b4700;
  --warn-mark: #fbb315;
  --chip: #efefef;
  --focus: #257de0;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0b0b0b;
    --surface: #191919;
    --surface-2: #222222;
    --text: #efefef;
    --text-2: #9c9c9c;
    --grid: #303030;
    --axis: #474747;
    --border: rgba(255, 255, 255, 0.10);
    --series: #338ced;
    --series-hover: #6aabf1;
    --series-wash: rgba(51, 140, 237, 0.14);
    --good: #53c556;
    --bad: #eb6263;
    --warn-bg: #2b2210;
    --warn-ink: #f6d58a;
    --chip: #2c2c2c;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--text); font-size: 14px; line-height: 1.45; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--series); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--text-2); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
[hidden] { display: none !important; }

/* --- barre du haut ------------------------------------------------------------------------- */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 650; letter-spacing: -0.01em; margin-right: 8px; }
.brand span { color: var(--text-2); font-weight: 500; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  border: 0; background: none; padding: 7px 12px; border-radius: 8px; cursor: pointer; color: var(--text-2);
  font-weight: 550;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab[aria-selected="true"] { background: var(--surface-2); color: var(--text); }
.ghost {
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
.ghost:hover { background: var(--surface-2); }

/* --- filtres ------------------------------------------------------------------------------- */
.filters { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 16px 24px 0; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 3px; }
.seg button {
  border: 0; background: none; padding: 5px 12px; border-radius: 7px; cursor: pointer; color: var(--text-2);
  font-weight: 550;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.updated { margin-left: auto; color: var(--text-2); font-size: 13px; display: flex; gap: 8px; align-items: center; }

main { padding: 16px 24px 48px; max-width: 1440px; }
main.loading { opacity: 0.55; transition: opacity 0.15s; }
.view { display: grid; gap: 16px; }

/* --- cartes ------------------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.card h2 { margin: 0 0 2px; font-size: 15px; font-weight: 650; }
.card .sub { margin: 0 0 12px; color: var(--text-2); font-size: 13px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.link-btn { border: 0; background: none; color: var(--series); cursor: pointer; padding: 0; font-weight: 550; }
.link-btn:hover { text-decoration: underline; }

/* bandeau file d'attente */
.alert {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-radius: var(--radius);
  background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--border);
}
.alert strong { font-weight: 650; }
.alert .link-btn { color: inherit; text-decoration: underline; }

/* --- tuiles KPI ---------------------------------------------------------------------------- */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { color: var(--text-2); font-size: 13px; }
.tile .value { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; margin: 2px 0; }
.tile .extra { font-size: 13px; color: var(--text-2); }
.delta { font-size: 13px; font-weight: 550; }
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }
.delta.flat { color: var(--text-2); font-weight: 500; }

/* --- graphiques ----------------------------------------------------------------------------- */
.multiples { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.mini h3 { margin: 0; font-size: 13px; font-weight: 550; color: var(--text-2); }
.mini .total { font-size: 22px; font-weight: 650; margin: 2px 0 6px; }
.chart { width: 100%; display: block; overflow: visible; }
.chart:focus-visible { outline-offset: 4px; border-radius: 4px; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { fill: var(--text-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--series); }
.chart .bar.on { fill: var(--series-hover); }
.chart .hit { fill: transparent; cursor: default; }
.table-toggle { margin-top: 10px; }

.tooltip {
  position: fixed; z-index: 50; pointer-events: none; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 8px; padding: 8px 10px; font-size: 13px;
  min-width: 120px;
}
.tooltip .t-value { font-weight: 650; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.tooltip .t-key { display: inline-block; width: 12px; height: 2px; background: var(--series); border-radius: 1px; }
.tooltip .t-label { color: var(--text-2); }

/* parcours (barres horizontales, une teinte) */
.funnel { display: grid; gap: 10px; }
.funnel .row { display: grid; grid-template-columns: minmax(150px, 210px) 1fr auto; gap: 12px; align-items: center; }
.funnel .name { font-size: 13px; }
.funnel .track { height: 16px; position: relative; }
.funnel .fill { height: 16px; background: var(--series); border-radius: 0 4px 4px 0; min-width: 0; }
.funnel .fig { font-size: 13px; white-space: nowrap; }
.funnel .fig strong { font-weight: 650; }

.delays { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.delays .tile .value { font-size: 22px; }

/* --- tableaux ------------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--grid); text-align: left; vertical-align: top; }
th { color: var(--text-2); font-weight: 550; white-space: nowrap; position: sticky; top: 0; background: var(--surface); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th .arrow { font-size: 10px; margin-left: 3px; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
td .small { display: block; color: var(--text-2); font-size: 12px; }
td.verdict { min-width: 230px; }
td.verdict > span:first-child { white-space: nowrap; }
td.verdict .small { white-space: normal; }
.empty { color: var(--text-2); padding: 18px 0; text-align: center; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; background: var(--chip);
  font-size: 12px; font-weight: 550; white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-2); }
.chip.client .dot { background: var(--good); }
.chip.wrote .dot { background: var(--series); }
.chip.pending .dot { background: var(--warn-mark); }
.chip.left .dot, .chip.stale .dot { background: var(--axis); }
.chip.in .dot { background: var(--text-2); }

.lead-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.lead-filters input, .lead-filters select {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; min-height: 34px;
}
.lead-filters input { min-width: 240px; }
.count { color: var(--text-2); font-size: 13px; margin-left: auto; }

/* --- fiche lead (panneau latéral) ------------------------------------------------------------- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.25); z-index: 30; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); z-index: 40; background: var(--surface);
  border-left: 1px solid var(--border); box-shadow: var(--shadow); overflow-y: auto; padding: 18px 22px 40px;
}
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.drawer h2 { margin: 0; font-size: 18px; }
.drawer h3 { font-size: 13px; color: var(--text-2); font-weight: 600; margin: 20px 0 8px; text-transform: none; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 13px; margin: 0; }
.facts dt { color: var(--text-2); }
.facts dd { margin: 0; word-break: break-word; }
.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--grid); }
.timeline li { position: relative; padding: 0 0 14px 16px; }
.timeline li::before {
  content: ""; position: absolute; left: -6px; top: 5px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--series); box-shadow: 0 0 0 2px var(--surface);
}
.timeline li.sale::before, .timeline li.qualified::before { background: var(--good); }
.timeline li.left::before { background: var(--axis); }
.timeline .when { color: var(--text-2); font-size: 12px; }
.timeline .what { font-weight: 550; }
.timeline .detail { color: var(--text-2); font-size: 13px; }

.note { color: var(--text-2); font-size: 13px; margin: 4px 0 0; }

/* --- connexion ---------------------------------------------------------------------------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login form { width: min(360px, 100%); display: grid; gap: 14px; }
.login h1 { margin: 0; font-size: 20px; }
.login label { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); }
.login input {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; color: var(--text);
}
.login .primary {
  border: 0; border-radius: 8px; padding: 10px 14px; background: #1b64be; color: #fff; font-weight: 600; cursor: pointer;
}
.login .primary:hover { background: #1757ac; }  /* blanc sur #1b64be : 5,9:1 */
.login .error { color: var(--bad); font-size: 13px; min-height: 1em; margin: 0; }

@media (max-width: 720px) {
  .top, .filters { padding-left: 14px; padding-right: 14px; }
  main { padding: 12px 14px 40px; }
  .grid-2 { grid-template-columns: 1fr; }
  .funnel .row { grid-template-columns: 1fr auto; }
  .funnel .track { grid-column: 1 / -1; order: 3; }
  .lead-filters input { min-width: 0; flex: 1; }
}
.tight { margin: 0; }
