/* ═══ Société Générale-style institutional UI ═══ */
:root {
  --white: #FFFFFF;
  --grey-50: #F7F8FA;
  --grey-100: #EEF1F5;
  --grey-150: #E1E5EC;
  --grey-200: #CDD3DC;
  --grey-300: #A6ADBA;
  --grey-400: #6F7785;
  --grey-500: #4A515E;
  --grey-700: #2A2F3A;
  --ink: #0F1320;
  --ink-2: #1B2030;
  --red: #E60028;
  --red-2: #B8001F;
  --red-soft: #FDE6EA;
  --green: #007A5E;
  --green-soft: #DCEFE7;
  --orange: #D67900;
  --orange-soft: #FBEED4;
  --blue: #0050B5;
  --blue-soft: #DCE8F6;

  --sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --s1:4px; --s2:8px; --s3:12px; --s4:16px; --s5:20px;
  --s6:24px; --s8:32px; --s10:40px; --s12:48px;

  --radius: 0px;
  --t-fast: 100ms ease-out;

  --topbar-h: 48px;
  --tabs-h: 40px;
  --sidebar-w: 248px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow-x: hidden; }
body {
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--grey-50);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; background: none; border: none; padding: 0; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-feature-settings:'tnum' 1; }
::selection { background: var(--ink); color: #fff; }

/* ═══ Top bar institutionnel ═══ */
.topbar {
  height: var(--topbar-h);
  background: var(--ink);
  color: #fff;
  display: flex; align-items: center;
  padding: 0 var(--s5);
  gap: var(--s5);
  border-bottom: 3px solid var(--red);
  position: sticky; top: 0; z-index: 50;
}
.tb-logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.tb-logo-mark {
  width: 24px; height: 24px;
  background: var(--ink);
  position: relative; display: inline-block; flex-shrink: 0;
}
.tb-logo-mark::before {
  content: ""; position: absolute; inset: 5px; background: var(--red);
}
.tb-logo-mark::after {
  content: ""; position: absolute; left: 5px; top: 5px;
  width: 5px; height: 5px; background: #fff;
}
.tb-divider { width: 1px; height: 22px; background: rgba(255,255,255,0.15); }
.tb-context { font-size: 12px; color: rgba(255,255,255,0.7); display: flex; align-items: center; gap: 8px; }
.tb-context b { color: #fff; font-weight: 500; }
.tb-search { margin-left: auto; display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12); font-size: 12px; color: rgba(255,255,255,0.75); width: 320px; cursor: pointer; transition: background var(--t-fast); }
.tb-search:hover { background: rgba(255,255,255,0.13); }
.tb-search svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.tb-search .kbd { margin-left: auto; font-family: var(--mono); font-size: 10.5px; padding: 1px 5px; background: rgba(255,255,255,0.10); color: rgba(255,255,255,0.65); }
.tb-actions { display: flex; align-items: center; gap: 4px; }
.tb-icon-btn { width: 30px; height: 30px; display: grid; place-items: center; color: rgba(255,255,255,0.65); position: relative; transition: color var(--t-fast), background var(--t-fast); }
.tb-icon-btn:hover { color:#fff; background: rgba(255,255,255,0.06); }
.tb-icon-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.tb-badge { position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; background: var(--red); border-radius: 50%; }
.tb-user { display: flex; align-items: center; gap: 8px; padding: 0 8px; font-size: 12px; color: rgba(255,255,255,0.85); }
.tb-user-avatar { width: 26px; height: 26px; background: var(--grey-150); color: var(--ink); display: grid; place-items: center; font-weight: 600; font-size: 11px; }

/* ═══ Tabs primaires ═══ */
.tabs { height: var(--tabs-h); background: #fff; border-bottom: 1px solid var(--grey-150); display: flex; align-items: stretch; padding: 0 var(--s5); position: sticky; top: var(--topbar-h); z-index: 49; }
.tab { display: flex; align-items: center; gap: 8px; padding: 0 14px; font-size: 12.5px; font-weight: 500; color: var(--grey-500); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color var(--t-fast), border-color var(--t-fast); white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--red); }
.tab svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.tab-count { font-family: var(--mono); font-size: 11px; padding: 1px 6px; background: var(--grey-100); color: var(--grey-500); }
.tab.active .tab-count { background: var(--ink); color: #fff; }
.tab-count.alert { background: var(--red-soft); color: var(--red-2); }

/* ═══ App body ═══ */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: calc(100vh - var(--topbar-h) - var(--tabs-h)); }

/* ═══ Sidebar ═══ */
.sidebar { background: #fff; border-right: 1px solid var(--grey-150); padding: var(--s4) 0; position: sticky; top: calc(var(--topbar-h) + var(--tabs-h)); height: calc(100vh - var(--topbar-h) - var(--tabs-h)); overflow-y: auto; }
.sb-section { padding: var(--s3) var(--s4) 0; }
.sb-section-title { font-size: 10.5px; font-weight: 600; color: var(--grey-400); letter-spacing: 0.06em; text-transform: uppercase; padding: 0 8px var(--s2); display: flex; align-items: center; justify-content: space-between; }
.sb-section-title button { color: var(--grey-300); }
.sb-section-title button:hover { color: var(--ink); }
.sb-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px; font-size: 13px; color: var(--grey-700); border-left: 2px solid transparent; transition: background var(--t-fast), border-color var(--t-fast); }
.sb-link:hover { background: var(--grey-50); }
.sb-link.active { background: var(--grey-50); border-left-color: var(--red); color: var(--ink); font-weight: 500; }
.sb-link svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.7; flex-shrink: 0; }
.sb-count { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--grey-400); }
.sb-count.alert { color: var(--red); font-weight: 600; }
.sb-stage-row { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; padding: 5px 10px 5px 12px; font-size: 12.5px; color: var(--grey-700); transition: background var(--t-fast); cursor: pointer; }
.sb-stage-row:hover { background: var(--grey-50); }
.sb-stage-mark { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.sb-stage-row .mono { font-size: 11px; color: var(--grey-400); }

/* ═══ Main content ═══ */
.main { min-width: 0; }

/* ═══ Page header ═══ */
.page-head { background: #fff; border-bottom: 1px solid var(--grey-150); padding: var(--s5) var(--s6); }
.crumb { font-size: 11.5px; color: var(--grey-400); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.crumb a:hover { color: var(--ink); }
.crumb-sep { color: var(--grey-300); }
.page-title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s5); margin-bottom: var(--s4); }
.page-title { font-size: 22px; font-weight: 600; letter-spacing: -0.012em; }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* KPI strip */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--grey-150); }
.kpi { padding: var(--s4) var(--s5); border-right: 1px solid var(--grey-150); }
.kpi:last-child { border-right: none; }
.kpi .l { font-size: 11px; color: var(--grey-400); letter-spacing: 0.04em; text-transform: uppercase; font-weight: 500; margin-bottom: 6px; }
.kpi .v { font-size: 22px; font-weight: 600; color: var(--ink); font-feature-settings: 'tnum' 1; letter-spacing: -0.015em; display: flex; align-items: baseline; gap: 6px; }
.kpi .v small { font-size: 12px; color: var(--grey-400); font-weight: 400; }
.kpi .delta { font-size: 11px; font-family: var(--mono); margin-top: 4px; }
.kpi .delta.up { color: var(--green); }
.kpi .delta.down { color: var(--red); }

/* ═══ Buttons ═══ */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 12px; font-weight: 500; border: 1px solid transparent; transition: all var(--t-fast); white-space: nowrap; letter-spacing: 0.005em; }
.btn-line { background: #fff; color: var(--ink); border-color: var(--grey-200); }
.btn-line:hover { background: var(--grey-50); border-color: var(--grey-400); }
.btn-fill { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-fill:hover { background: var(--ink-2); }
.btn-red { background: var(--red); color: #fff; border-color: var(--red); }
.btn-red:hover { background: var(--red-2); border-color: var(--red-2); }
.btn-ghost { color: var(--grey-500); }
.btn-ghost:hover { background: var(--grey-100); color: var(--ink); }
.btn-icon { width: 28px; height: 28px; padding: 0; justify-content: center; }
.btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.7; flex-shrink: 0; }
.btn-icon svg { width: 14px; height: 14px; }
.kbd { font-family: var(--mono); font-size: 10.5px; padding: 1px 5px; background: rgba(0,0,0,0.07); color: var(--grey-500); margin-left: 4px; }
.btn-fill .kbd, .btn-red .kbd { background: rgba(255,255,255,0.18); color: rgba(255,255,255,0.8); }

/* ═══ Catalogue split ═══ */
.cat-split { display: grid; grid-template-columns: minmax(480px, 0.95fr) minmax(0, 1.05fr); height: calc(100vh - var(--topbar-h) - var(--tabs-h)); }
.cat-left { background: #fff; border-right: 1px solid var(--grey-150); display: flex; flex-direction: column; overflow: hidden; }
.cat-toolbar { padding: var(--s3) var(--s5); border-bottom: 1px solid var(--grey-150); display: flex; align-items: center; gap: var(--s3); background: var(--grey-50); }
.cat-filters { display: flex; gap: 0; flex-wrap: wrap; overflow-x: auto; }
.cat-filter { padding: 5px 10px; font-size: 11.5px; color: var(--grey-500); border: 1px solid var(--grey-200); border-right: none; background: #fff; font-weight: 500; white-space: nowrap; }
.cat-filter:last-child { border-right: 1px solid var(--grey-200); }
.cat-filter:hover { background: var(--grey-50); }
.cat-filter.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.cat-toolbar-meta { margin-left: auto; font-size: 11.5px; color: var(--grey-400); font-family: var(--mono); }
.cat-toolbar-meta b { color: var(--ink); font-weight: 600; }
.cat-thead { display: grid; grid-template-columns: 24px 1fr 90px 90px 70px; gap: var(--s3); padding: 8px var(--s5); border-bottom: 1px solid var(--grey-200); background: var(--grey-50); font-size: 10.5px; font-weight: 600; color: var(--grey-500); text-transform: uppercase; letter-spacing: 0.05em; position: sticky; top: 0; }
.cat-thead .right { text-align: right; }
.cat-list { flex: 1; overflow-y: auto; }
.cat-row { display: grid; grid-template-columns: 24px 1fr 90px 90px 70px; gap: var(--s3); padding: 10px var(--s5); border-bottom: 1px solid var(--grey-100); cursor: pointer; transition: background var(--t-fast); align-items: center; }
.cat-row:hover { background: var(--grey-50); }
.cat-row.selected { background: var(--blue-soft); border-left: 3px solid var(--blue); padding-left: calc(var(--s5) - 3px); }
.cat-row-stage { width: 8px; height: 8px; border-radius: 50%; margin-left: 8px; display: inline-block; }
.cat-row-mid { min-width: 0; }
.cat-row-loc { font-size: 13px; font-weight: 500; color: var(--ink); margin-bottom: 2px; display: flex; align-items: center; gap: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-row-loc .id { font-family: var(--mono); font-size: 10.5px; color: var(--grey-300); font-weight: 400; }
.cat-row-meta { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--grey-500); }
.cat-row-meta .sep { color: var(--grey-300); }
.cat-row-stage-pill { font-size: 10.5px; font-weight: 500; color: var(--grey-500); white-space: nowrap; text-align: right; }
.cat-row-price { font-family: var(--mono); font-size: 12.5px; font-weight: 600; text-align: right; color: var(--ink); }
.cat-row-aging { font-family: var(--mono); font-size: 11px; text-align: right; color: var(--grey-400); }
.cat-row-aging.warm { color: var(--orange); }
.cat-row-aging.hot { color: var(--red); font-weight: 600; }
.src-mark { font-family: var(--mono); font-size: 9.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--grey-500); padding: 1px 5px; border: 1px solid var(--grey-200); background: #fff; display: inline-block; }

/* Stage colors */
.s-detecte  { background: var(--grey-300); }
.s-prepare  { background: var(--blue); }
.s-envoye   { background: var(--blue); }
.s-rappele  { background: var(--orange); }
.s-reponse  { background: #6E5BBF; }
.s-rdv      { background: var(--green); }
.s-mandat   { background: var(--green); }
.s-signe    { background: var(--red); }

/* ═══ Fiche right pane ═══ */
.cat-right { background: var(--grey-50); overflow-y: auto; height: calc(100vh - var(--topbar-h) - var(--tabs-h)); }
.fiche-head { background: #fff; padding: var(--s5) var(--s6); border-bottom: 1px solid var(--grey-150); }
.fiche-head-eyebrow { display: flex; align-items: center; gap: var(--s3); font-size: 11px; color: var(--grey-400); margin-bottom: 8px; flex-wrap: wrap; }
.fiche-head-eyebrow .stage-badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; font-weight: 600; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; }
.fiche-head-eyebrow .stage-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.stage-badge.s-detecte-badge  { background: var(--grey-100); color: var(--grey-500); } .stage-badge.s-detecte-badge::before  { background: var(--grey-300); }
.stage-badge.s-prepare-badge  { background: var(--blue-soft); color: var(--blue); }    .stage-badge.s-prepare-badge::before  { background: var(--blue); }
.stage-badge.s-envoye-badge   { background: var(--blue-soft); color: var(--blue); }    .stage-badge.s-envoye-badge::before   { background: var(--blue); }
.stage-badge.s-rappele-badge  { background: var(--orange-soft); color: var(--orange); }.stage-badge.s-rappele-badge::before  { background: var(--orange); }
.stage-badge.s-reponse-badge  { background: #EEE9FF; color: #6E5BBF; }                .stage-badge.s-reponse-badge::before  { background: #6E5BBF; }
.stage-badge.s-rdv-badge      { background: var(--green-soft); color: var(--green); }  .stage-badge.s-rdv-badge::before      { background: var(--green); }
.stage-badge.s-mandat-badge   { background: var(--green-soft); color: var(--green); }  .stage-badge.s-mandat-badge::before   { background: var(--green); }
.stage-badge.s-signe-badge    { background: var(--red-soft); color: var(--red); }      .stage-badge.s-signe-badge::before    { background: var(--red); }
.fiche-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s5); }
.fiche-title-block { min-width: 0; }
.fiche-title { font-size: 24px; font-weight: 600; letter-spacing: -0.015em; margin-bottom: 4px; }
.fiche-subtitle { font-size: 13.5px; color: var(--grey-500); font-family: var(--mono); font-feature-settings: 'tnum' 1; }
.fiche-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }
.fiche-kpis { display: grid; grid-template-columns: repeat(6, 1fr); background: #fff; border-bottom: 1px solid var(--grey-150); }
.fiche-kpi { padding: 12px var(--s4); border-right: 1px solid var(--grey-100); }
.fiche-kpi:last-child { border-right: none; }
.fiche-kpi .l { font-size: 10px; color: var(--grey-400); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; margin-bottom: 4px; }
.fiche-kpi .v { font-size: 15px; font-weight: 600; color: var(--ink); font-feature-settings: 'tnum' 1; letter-spacing: -0.01em; }
.fiche-kpi .v small { font-size: 11px; color: var(--grey-400); font-weight: 400; margin-left: 2px; }
.fiche-kpi.warn .v { color: var(--orange); }
.fiche-kpi.pos .v { color: var(--green); }
.fiche-body { padding: var(--s5) var(--s6) var(--s10); display: flex; flex-direction: column; gap: var(--s4); }

/* ═══ Cards ═══ */
.card { background: #fff; border: 1px solid var(--grey-150); }
.card-head { padding: 10px var(--s4); border-bottom: 1px solid var(--grey-150); display: flex; align-items: center; justify-content: space-between; background: var(--grey-50); }
.card-title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-title svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.7; color: var(--grey-400); }
.card-meta { font-size: 11px; color: var(--grey-400); font-family: var(--mono); }
.card-body { padding: var(--s4); }

/* ═══ Action chips & interactions ═══ */
.actions-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--s4); }
.action-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--grey-200); background: #fff; font-size: 12px; color: var(--grey-700); font-weight: 500; }
.action-chip:hover { border-color: var(--ink); background: var(--grey-50); }
.action-chip svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.note-input { width: 100%; padding: 8px 10px; border: 1px solid var(--grey-200); background: var(--grey-50); font-size: 12.5px; resize: none; outline: none; transition: border-color var(--t-fast), background var(--t-fast); }
.note-input:focus { border-color: var(--ink); background: #fff; }
.note-input::placeholder { color: var(--grey-400); }

/* ═══ Timeline ═══ */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 110px 24px 1fr; gap: var(--s3); padding: 10px 0; border-bottom: 1px solid var(--grey-100); align-items: flex-start; }
.tl-item:last-child { border-bottom: none; }
.tl-date { font-family: var(--mono); font-size: 11px; color: var(--grey-400); padding-top: 3px; }
.tl-icon { width: 24px; height: 24px; background: var(--grey-100); display: grid; place-items: center; color: var(--grey-500); }
.tl-icon svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.tl-icon.pos { background: var(--green-soft); color: var(--green); }
.tl-icon.neu { background: var(--blue-soft); color: var(--blue); }
.tl-icon.alert { background: var(--red-soft); color: var(--red); }
.tl-body .h { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 2px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-body .h .author { color: var(--grey-400); font-weight: 400; font-size: 11.5px; }
.tl-body .b { font-size: 12.5px; color: var(--grey-500); line-height: 1.55; }
.tag { display: inline-block; padding: 1px 7px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.tag-pos { background: var(--green-soft); color: var(--green); }
.tag-neu { background: var(--grey-100); color: var(--grey-500); }
.tag-warn { background: var(--orange-soft); color: var(--orange); }

/* ═══ Two col & definition table ═══ */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
.def-table { width: 100%; border-collapse: collapse; }
.def-table tr { border-bottom: 1px solid var(--grey-100); }
.def-table tr:last-child { border-bottom: none; }
.def-table td { padding: 7px 0; font-size: 12.5px; vertical-align: top; }
.def-table td:first-child { color: var(--grey-400); width: 130px; padding-right: var(--s3); font-weight: 500; }
.def-table td:last-child { color: var(--ink); }
.def-table .mono { font-family: var(--mono); font-size: 12px; }

/* ═══ Pipeline ═══ */
.pipeline-wrap { padding: var(--s5) var(--s6) var(--s10); display: flex; flex-direction: column; gap: var(--s4); }
.funnel-card { background: #fff; border: 1px solid var(--grey-150); padding: var(--s5); }
.funnel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s4); }
.funnel-head h3 { font-size: 14px; font-weight: 600; }
.funnel-bars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 1px; align-items: end; height: 110px; padding: 28px 0; background: var(--grey-50); border: 1px solid var(--grey-100); position: relative; }
.funnel-bar { background: var(--ink); position: relative; min-height: 4px; margin: 0 8px; }
.funnel-bar:last-child { background: var(--red); }
.funnel-bar:hover { opacity: 0.85; }
.funnel-bar .v { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--ink); }
.funnel-bar .l { position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); font-size: 10.5px; color: var(--grey-500); white-space: nowrap; font-weight: 500; }
.pipeline-table-card { background: #fff; border: 1px solid var(--grey-150); }
.pipeline-thead { display: grid; grid-template-columns: 230px 90px 90px 1fr 90px; gap: var(--s4); padding: 10px var(--s4); border-bottom: 1px solid var(--grey-200); background: var(--grey-50); font-size: 10.5px; font-weight: 600; color: var(--grey-500); text-transform: uppercase; letter-spacing: 0.05em; }
.pipeline-thead .right { text-align: right; }
.pipeline-row { display: grid; grid-template-columns: 230px 90px 90px 1fr 90px; gap: var(--s4); padding: 14px var(--s4); border-bottom: 1px solid var(--grey-100); align-items: center; }
.pipeline-row:last-child { border-bottom: none; }
.pipeline-row:hover { background: var(--grey-50); }
.pipeline-stage-name { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; }
.pipeline-stage-mark { width: 10px; height: 10px; flex-shrink: 0; border-radius: 50%; display: inline-block; }
.pipeline-stage-meta { font-size: 11px; color: var(--grey-400); font-weight: 400; margin-top: 2px; }
.pipeline-count { font-family: var(--mono); font-size: 18px; font-weight: 600; text-align: right; color: var(--ink); font-feature-settings: 'tnum' 1; }
.pipeline-conv { font-family: var(--mono); font-size: 12px; text-align: right; color: var(--grey-500); }
.mini-cards-row { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0; }
.mini-card { flex-shrink: 0; min-width: 160px; padding: 7px 9px; border: 1px solid var(--grey-150); background: #fff; cursor: pointer; }
.mini-card:hover { border-color: var(--grey-400); background: var(--grey-50); }
.mini-card-loc { font-size: 12px; font-weight: 500; color: var(--ink); margin-bottom: 2px; line-height: 1.2; }
.mini-card-meta { font-family: var(--mono); font-size: 10.5px; color: var(--grey-400); }
.mini-card-more { flex-shrink: 0; min-width: 70px; display: grid; place-items: center; font-size: 11px; color: var(--grey-400); font-weight: 500; border: 1px dashed var(--grey-200); }
.pipeline-trend { text-align: right; font-family: var(--mono); font-size: 11.5px; font-weight: 600; color: var(--grey-400); }
.pipeline-trend.up { color: var(--green); }
.pipeline-trend.down { color: var(--red); }

/* ═══ Briefing ═══ */
.briefing-wrap { padding: var(--s5) var(--s6) var(--s10); display: flex; flex-direction: column; gap: var(--s4); max-width: 1280px; }
.brief-hero { background: #fff; border: 1px solid var(--grey-150); padding: var(--s5) var(--s6); }
.brief-date { font-size: 11px; color: var(--grey-400); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; margin-bottom: 8px; }
.brief-greeting { font-size: 26px; font-weight: 600; letter-spacing: -0.018em; margin-bottom: 4px; }
.brief-lede { font-size: 14px; color: var(--grey-500); max-width: 760px; line-height: 1.55; }
.brief-lede b { color: var(--ink); font-weight: 600; }
.brief-lede .alert { color: var(--red); font-weight: 600; }
.brief-grid { display: grid; grid-template-columns: 2fr 1fr; gap: var(--s4); }
.task-row { display: grid; grid-template-columns: 16px 1fr 80px; gap: var(--s3); padding: 9px 0; border-bottom: 1px solid var(--grey-100); align-items: center; }
.task-row:last-child { border-bottom: none; }
.task-check { width: 14px; height: 14px; border: 1.5px solid var(--grey-300); background: #fff; cursor: pointer; -webkit-appearance: none; appearance: none; }
.task-check:hover { border-color: var(--ink); }
.task-check:checked { background: var(--ink); border-color: var(--ink); }
.task-row .who { font-size: 13px; color: var(--ink); font-weight: 500; }
.task-row .who small { display: block; color: var(--grey-400); font-size: 11.5px; font-weight: 400; margin-top: 1px; }
.task-row .when { font-family: var(--mono); font-size: 11px; color: var(--grey-400); text-align: right; }
.task-row.overdue .when { color: var(--red); font-weight: 600; }
.feed-item { padding: 10px 0; border-bottom: 1px solid var(--grey-100); font-size: 12.5px; line-height: 1.55; }
.feed-item:last-child { border-bottom: none; }
.feed-item .t { font-family: var(--mono); font-size: 10.5px; color: var(--grey-400); display: block; margin-bottom: 3px; }
.feed-item b { font-weight: 600; }

/* ═══ Tâches ═══ */
.taches-wrap { padding: var(--s5) var(--s6) var(--s10); display: flex; flex-direction: column; gap: var(--s6); }
.taches-section { display: flex; flex-direction: column; }
.taches-section-title { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--grey-400); padding-bottom: var(--s3); border-bottom: 1px solid var(--grey-150); margin-bottom: var(--s3); display: flex; align-items: center; justify-content: space-between; }
.taches-section-title.overdue-title { color: var(--red); }

/* ═══ Statistiques placeholder ═══ */
.stats-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 400px; gap: var(--s4); color: var(--grey-400); text-align: center; padding: var(--s10); }
.stats-placeholder h2 { font-size: 18px; font-weight: 600; color: var(--grey-500); }
.stats-placeholder p { font-size: 13px; max-width: 400px; line-height: 1.6; }

/* ═══ Empty state ═══ */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--s10); text-align: center; color: var(--grey-400); gap: var(--s3); }
.empty-state h3 { font-size: 14px; font-weight: 600; color: var(--grey-500); }
.empty-state p { font-size: 12.5px; }

/* ═══ Command palette ═══ */
.cmdk-overlay { position: fixed; inset: 0; background: rgba(15,19,32,0.55); display: none; align-items: flex-start; justify-content: center; padding-top: 12vh; z-index: 200; }
.cmdk-overlay.open { display: flex; }
.cmdk { background: #fff; width: 560px; max-width: 92vw; box-shadow: 0 30px 80px rgba(0,0,0,0.25); border: 1px solid var(--grey-200); }
.cmdk-input-wrap { display: flex; align-items: center; gap: var(--s3); padding: var(--s4); border-bottom: 1px solid var(--grey-150); }
.cmdk-input-wrap svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; color: var(--grey-400); }
.cmdk-input { flex: 1; font-size: 14px; outline: none; }
.cmdk-input::placeholder { color: var(--grey-400); }
.cmdk-section-title { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--grey-400); padding: var(--s3) var(--s4) 4px; }
.cmdk-item { display: flex; align-items: center; gap: var(--s3); padding: 8px var(--s4); font-size: 13px; cursor: pointer; }
.cmdk-item svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.7; color: var(--grey-400); }
.cmdk-item:hover, .cmdk-item.sel { background: var(--blue-soft); }
.cmdk-item .meta { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: var(--grey-400); }
.cmdk-foot { padding: 8px var(--s4); border-top: 1px solid var(--grey-150); background: var(--grey-50); font-size: 11px; color: var(--grey-400); display: flex; gap: var(--s4); }
.cmdk-foot b { color: var(--grey-700); font-weight: 600; }

/* ═══ Scrollbar ═══ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--grey-50); }
::-webkit-scrollbar-thumb { background: var(--grey-200); }
::-webkit-scrollbar-thumb:hover { background: var(--grey-300); }

/* ═══ Toast notifications ═══ */
#sg-toasts { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.sg-toast { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 500; min-width: 240px; box-shadow: 0 4px 16px rgba(0,0,0,0.18); border-left: 3px solid var(--grey-300); animation: sg-toast-in 120ms ease-out forwards; }
.sg-toast.success { border-left-color: var(--green); }
.sg-toast.error   { border-left-color: var(--red); }
.sg-toast.info    { border-left-color: var(--blue); }
.sg-toast.warning { border-left-color: var(--orange); }
.sg-toast.out     { animation: sg-toast-out 180ms ease-out forwards; }
@keyframes sg-toast-in  { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
@keyframes sg-toast-out { from { opacity:1; } to { opacity:0; transform:translateY(8px); } }

/* ═══ Skeleton pulse ═══ */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* ═══ Sidebar drawer (mobile) ═══ */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,19,32,0.45);
  z-index: 60;
}
.sidebar-overlay.open { display: block; }

/* Burger caché sur desktop */
.tb-burger {
  display: none;
  width: 30px; height: 30px;
  align-items: center; justify-content: center;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
}
.tb-burger:hover { color: #fff; }
.tb-burger svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }

/* Bouton retour fiche (mobile) */
.fiche-back-btn {
  display: none;
  align-items: center; gap: 8px;
  padding: var(--s3) var(--s6);
  background: #fff;
  border-bottom: 1px solid var(--grey-150);
  font-size: 12px;
  color: var(--grey-500);
  cursor: pointer;
}
.fiche-back-btn:hover { color: var(--ink); }
.fiche-back-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.7; }

/* ═══ Responsive ═══ */
@media (max-width: 1180px) {
  .cat-split { grid-template-columns: 420px 1fr; }
  .fiche-kpis { grid-template-columns: repeat(3, 1fr); }
  .fiche-kpi:nth-child(3n) { border-right: none; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    display: block !important;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 61;
    transform: translateX(-100%);
    transition: transform 200ms ease-out;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .tb-burger {
    display: flex !important;
  }
  .cat-split {
    grid-template-columns: 1fr;
    height: auto;
  }
  .cat-right {
    display: none;
    position: fixed; inset: 0;
    z-index: 55;
    overflow-y: auto;
    background: var(--grey-50);
    height: auto;
  }
  .cat-right.active {
    display: block;
  }
  .fiche-back-btn {
    display: flex !important;
  }
  .brief-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .pipeline-thead, .pipeline-row { grid-template-columns: 1fr 60px 60px; }
  .pipeline-row > *:nth-child(4), .pipeline-thead > *:nth-child(4) { display: none; }
  .pipeline-row > *:nth-child(5), .pipeline-thead > *:nth-child(5) { display: none; }
}

@media (max-width: 640px) {
  /* Anti-zoom iOS : inputs 16px minimum */
  input, select, textarea { font-size: 16px !important; }
  .topbar { padding: 0 var(--s3); gap: var(--s3); }
  .tb-search { display: none; }
  .tb-context { display: none; }
  .fiche-kpis { grid-template-columns: repeat(2, 1fr); }
  .pipeline-wrap { padding: var(--s4) var(--s4) var(--s8); }
  .briefing-wrap { padding: var(--s4) var(--s4) var(--s8); }
  .taches-wrap   { padding: var(--s4) var(--s4) var(--s8); }
  .page-head     { padding: var(--s4); }
  .kpis          { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(2n) { border-right: none; }
  .brief-grid    { grid-template-columns: 1fr; }
  .page-title    { font-size: 18px; }
  .tabs          { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab           { padding: 0 10px; font-size: 11.5px; }
  .funnel-bars   { height: 80px; }
}

/* ═══ Responsive additionnels ═══ */

/* Catalogue toolbar — selects wrappent sur mobile */
@media (max-width: 760px) {
  .cat-toolbar { flex-wrap: wrap; gap: var(--s2); }
  .cat-toolbar select, .cat-toolbar .btn { font-size: 11px; padding: 4px 7px; }
  .cat-toolbar-meta { display: none; }
  #rapid-chip { font-size: 10px; padding: 3px 6px; }
}

/* Page actions — wrap sur mobile */
@media (max-width: 640px) {
  .page-title-row { flex-direction: column; align-items: flex-start; gap: var(--s3); }
  .page-actions { flex-wrap: wrap; }
  .page-actions .btn { font-size: 11px; padding: 5px 10px; }
  .cat-thead { display: none; }

  /* Catalogue toolbar stack */
  .cat-toolbar { flex-direction: column; align-items: stretch; }
  .cat-toolbar select { width: 100%; }

  /* Find page — filtres stack */
  #search-filters-row { flex-direction: column; }
  #search-filters-row select { width: 100%; }

  /* RDV page — task-row simplifié */
  .rdv-upcoming-row { grid-template-columns: 80px 1fr 80px !important; }
  .rdv-upcoming-row > *:nth-child(3) { display: none; }

  /* Pipeline funnel scroll */
  .funnel-bars { overflow-x: auto; min-width: 480px; }
  .funnel-card { overflow-x: auto; }

  /* Modals — plein écran sur mobile */
  .cmdk { width: 95vw !important; max-width: 95vw !important; margin: 0 auto; }

  /* Tabs — hide count sur très petit écran */
  .tab-count { display: none; }

  /* Briefing task-row */
  .task-row { grid-template-columns: 16px 1fr 60px !important; }
  .task-row .when { font-size: 10px; }
}

/* Tablette (760-900px) */
@media (min-width: 641px) and (max-width: 900px) {
  .page-title { font-size: 19px; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .cat-toolbar { gap: var(--s2); }
  .fiche-kpis { grid-template-columns: repeat(3, 1fr); }
  .fiche-kpi:nth-child(3n) { border-right: none; }
}

/* ═══ FIXES MOBILES CRITIQUES ═══ */

/* 1. Supprimer border-radius natif iOS sur les selects */
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border-radius: 0 !important;
  -webkit-border-radius: 0 !important;
}

/* 2. Topbar — masquer le nom user sur mobile, garder avatar */
@media (max-width: 640px) {
  .tb-user span:first-child { display: none; }
  .tb-context { display: none; }
  .tb-divider { display: none; }
  .tb-search { display: none; }
  .tb-actions { gap: 2px; }
  .tb-icon-btn { width: 26px; height: 26px; }
  .topbar { padding: 0 var(--s3); gap: var(--s2); overflow: hidden; }
  .tb-logo span { font-size: 13px; }
}

/* 3. Cat-row — layout 2 colonnes sur mobile */
@media (max-width: 640px) {
  .cat-row {
    grid-template-columns: 16px 1fr 55px !important;
    gap: var(--s2) !important;
    padding: 10px var(--s3) !important;
  }
  .cat-row-stage { margin-left: 0; }
  /* Masquer colonnes prix et âge — garder dot, contenu, stage-pill */
  .cat-row > *:nth-child(4),
  .cat-row > *:nth-child(5) { display: none; }
  /* Stage pill à droite */
  .cat-row-stage-pill {
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* Contenu compact */
  .cat-row-loc { font-size: 12px; }
  .cat-row-meta { font-size: 11px; gap: 4px; flex-wrap: nowrap; overflow: hidden; }
  .src-mark { font-size: 8.5px; padding: 1px 3px; flex-shrink: 0; max-width: 70px; overflow: hidden; text-overflow: ellipsis; }

  /* KPIs catalogue : 2 colonnes strict */
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi:nth-child(2n) { border-right: none; }
  .kpi:nth-child(5) { border-right: none; grid-column: span 2; }
  .kpi .v { font-size: 18px; }
  .kpi .l { font-size: 10px; }
}

/* ═══ FICHE DETAIL — MOBILE ═══ */
@media (max-width: 640px) {
  /* Head de la fiche */
  .fiche-head { padding: var(--s3) var(--s4); }
  .fiche-head-eyebrow { font-size: 10px; gap: 6px; flex-wrap: wrap; }

  /* Titre + sous-titre */
  .fiche-title { font-size: 17px; letter-spacing: -0.01em; }
  .fiche-subtitle {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Actions fiche — scroll horizontal plutôt que débordement */
  .fiche-actions {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding-bottom: 4px;
    max-width: 100%;
  }
  .fiche-actions .btn {
    flex-shrink: 0;
    font-size: 11px;
    padding: 5px 8px;
    white-space: nowrap;
  }
  .fiche-actions .btn .kbd { display: none; } /* masquer kbd sur mobile */
  .fiche-title-row { flex-direction: column; gap: var(--s3); }
  .fiche-title-block { min-width: 0; width: 100%; }

  /* KPIs fiche — 2 colonnes */
  .fiche-kpis { grid-template-columns: repeat(2, 1fr); }
  .fiche-kpi:nth-child(2n) { border-right: none; }
  .fiche-kpi .v { font-size: 13px; }
  .fiche-kpi .l { font-size: 9px; }

  /* Body fiche */
  .fiche-body { padding: var(--s3) var(--s4) var(--s8); gap: var(--s3); }

  /* Card head — meta date tronquée */
  .card-head { flex-wrap: wrap; gap: 4px; }
  .card-meta {
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  /* Action chips — scroll horizontal */
  .actions-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }
  .action-chip { flex-shrink: 0; font-size: 11px; padding: 5px 8px; }

  /* Timeline */
  .tl-item { grid-template-columns: 80px 20px 1fr; gap: 6px; }
  .tl-date { font-size: 10px; }
  .tl-body .h { font-size: 12px; }
  .tl-body .b { font-size: 11.5px; }

  /* Def table */
  .def-table td { font-size: 11.5px; padding: 5px 0; }
  .def-table td:first-child { width: 90px; font-size: 11px; }
  .two-col { grid-template-columns: 1fr; gap: var(--s3); }

  /* Stage badge */
  .stage-badge { font-size: 9.5px; padding: 2px 6px; }
}

/* ═══ MODAL RDV — MOBILE ═══ */
@media (max-width: 640px) {
  /* Toutes les grilles 2col dans les modals passent en 1col */
  .cmdk [style*="grid-template-columns: 1fr 1fr"],
  .cmdk div[style*="display:grid"],
  .cmdk div[style*="display: grid"] {
    display: flex !important;
    flex-direction: column !important;
  }

  /* Boutons du modal — pleine largeur */
  .cmdk div[style*="justify-content:flex-end"],
  .cmdk div[style*="justify-content: flex-end"] {
    flex-direction: column !important;
    gap: 8px !important;
  }
  .cmdk div[style*="justify-content:flex-end"] .btn,
  .cmdk div[style*="justify-content: flex-end"] .btn {
    width: 100% !important;
    justify-content: center !important;
  }

  /* Padding modal réduit */
  .cmdk > div { padding: var(--s3) !important; }
  .cmdk-input-wrap { padding: var(--s3) var(--s4) !important; }
}

/* ═══ MODAL RDV — SCROLL MOBILE ═══ */
@media (max-width: 768px) {
  .cmdk-overlay {
    align-items: flex-start !important;
    padding-top: 0 !important;
    overflow-y: auto;
  }
  .cmdk {
    margin: 0 auto;
    max-height: 100dvh !important;
    display: flex;
    flex-direction: column;
    border-radius: 0 !important;
  }
  .cmdk > div:last-of-type {
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
  }
}

/* Desktop — limiter la hauteur aussi */
@media (min-width: 769px) {
  .cmdk-overlay {
    padding-top: 5vh;
    align-items: flex-start;
  }
  .cmdk {
    max-height: 90vh;
    display: flex;
    flex-direction: column;
  }
  .cmdk > div:last-of-type {
    overflow-y: auto;
    flex: 1;
  }
}

/* ═══ RDV PAGE — MOBILE ═══ */
@media (max-width: 640px) {
  /* Row RDV — simplifier la grille */
  .rdv-upcoming-row {
    grid-template-columns: auto 1fr auto !important;
    gap: var(--s2) !important;
  }
  /* Date en une ligne */
  .rdv-upcoming-row > *:first-child {
    white-space: nowrap;
    font-size: 11px !important;
    color: var(--grey-500);
  }
  /* Masquer la colonne notes (3ème enfant) */
  .rdv-upcoming-row > *:nth-child(3) {
    display: none;
  }
  /* Boutons sur même ligne */
  .rdv-upcoming-row > *:nth-child(4) {
    flex-direction: row !important;
    gap: 4px !important;
  }

  /* Topbar — nom user sur une ligne */
  .tb-user {
    max-width: 80px;
    overflow: hidden;
  }
  .tb-user span:first-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60px;
    font-size: 11px;
  }
}


/* ═══ Mobile touch targets (min 44px) ═══ */
@media (max-width: 768px) {
  .btn { min-height: 44px; }
  .btn-sm, .cat-toolbar .btn { min-height: 36px; }
  /* Annonce cards — plus aérées pour le touch */
  .ann-row { padding: var(--s3) var(--s4); min-height: 64px; }
  /* Tâches checkbox plus grande */
  .task-check { width: 22px; height: 22px; }
  /* Quick actions dans detail */
  .qa-btn { min-height: 40px; padding: 10px 14px; font-size: 13px; }
  /* Boutons résultat relance */
  .det-result-btn { min-height: 44px; padding: 10px 16px; font-size: 13px; }
  /* Bouton principal relance */
  #btn-relance-done { min-height: 52px; font-size: 15px; }
}
