/* CRM KONNECT — design system (thème clair uniquement).
   Pas de mode sombre, pas de police ni de ressource externe.
   Les noms de classes historiques sont conservés ; les composants récents
   (.btn, .chip, .kpi, .progress, .callout, .empty-state…) s'y ajoutent. */

:root {
  color-scheme: light;

  /* Surfaces et textes */
  --bg: #F7F6F3;
  --surface: #FFFFFF;
  --ink: #1C1B18;
  --muted: #5F5A53;
  --line: #E3E0D9;
  --line-strong: #CFCBC2;

  /* Accent (bleu nuit) */
  --accent: #26344A;
  --accent-hover: #1B2638;
  --accent-ink: #FFFFFF;
  --accent-soft: #EEF0F4;
  --focus: #2F6FDE;

  /* Navigation */
  --nav-bg: #FFFFFF;
  --nav-active-bg: #EEF0F4;

  /* Statuts pleins (texte blanc dessus, ou texte coloré sur fond clair) */
  --status-new: #6E6A63;
  --status-active: #26344A;
  --status-replied: #8C6708;
  --status-completed: #2F7A4F;
  --status-stopped: #A3402C;
  --success: #2F7A4F;
  --warning: #8C6708;
  --danger: #A3402C;

  /* Étiquettes (chips) : texte et fond teinté, contraste AA vérifié par test */
  --chip-new-fg: #4A4640;       --chip-new-bg: #ECEAE5;
  --chip-active-fg: #26344A;    --chip-active-bg: #E3E9F3;
  --chip-replied-fg: #6B4A00;   --chip-replied-bg: #FBEFD0;
  --chip-completed-fg: #1E5C3A; --chip-completed-bg: #DFF0E6;
  --chip-stopped-fg: #8A2E1C;   --chip-stopped-bg: #F8E2DC;
  --chip-success-fg: #1E5C3A;   --chip-success-bg: #DFF0E6;
  --chip-warning-fg: #6B4A00;   --chip-warning-bg: #FBEFD0;
  --chip-danger-fg: #8A2E1C;    --chip-danger-bg: #F8E2DC;
  --chip-info-fg: #26344A;      --chip-info-bg: #E3E9F3;
  --chip-muted-fg: #4A4640;     --chip-muted-bg: #ECEAE5;

  /* Échelle d'espacement 4 / 8 / 12 / 16 / 24 / 32 */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;

  /* Formes et ombres */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(28, 27, 24, 0.05);
  --shadow: 0 1px 3px rgba(28, 27, 24, 0.07), 0 1px 2px rgba(28, 27, 24, 0.04);

  /* Typographie */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.625rem;
  --fs-kpi: 2rem;

  /* Mise en page */
  --touch: 40px;
  --sidebar-w: 15rem;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Accessibilité ---------- */

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute;
  left: var(--sp-2);
  top: -4rem;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-ink);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus { top: var(--sp-2); color: var(--accent-ink); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Mise en page ---------- */

.container {
  max-width: 72rem;
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-4) var(--sp-6);
}

/* ---------- Coque : menu latéral (≥ 900 px) et barre supérieure repliable (mobile) ----------
   Le menu mobile fonctionne sans JavaScript : case à cocher #nav-toggle + libellé. */

.app-shell { min-height: 100vh; position: relative; }
.nav-toggle {
  position: absolute; top: 0; left: 0; width: 1px; height: 1px; margin: 0; opacity: 0;
}
.nav-toggle:focus-visible ~ .topbar .menu-button {
  outline: 2px solid var(--focus); outline-offset: 2px;
}
main:focus { outline: none; }

.brand {
  font-weight: 700; letter-spacing: 0.03em; color: var(--accent); text-decoration: none;
  font-size: var(--fs-md);
}
.brand:hover { color: var(--accent-hover); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  min-height: 56px; padding: var(--sp-2) var(--sp-4);
  background: var(--nav-bg); border-bottom: 1px solid var(--line);
}
.menu-button {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  min-height: var(--touch); padding: 0 var(--sp-3);
  background: var(--surface); color: var(--ink); font-weight: 600; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
.menu-icon, .menu-icon::before, .menu-icon::after {
  display: block; width: 16px; height: 2px; background: currentColor; border-radius: 1px;
}
.menu-icon { position: relative; }
.menu-icon::before, .menu-icon::after { content: ""; position: absolute; left: 0; }
.menu-icon::before { top: -5px; }
.menu-icon::after { top: 5px; }

.sidebar {
  display: none;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--line);
  padding: var(--sp-2) var(--sp-3) var(--sp-4);
}
.nav-toggle:checked ~ .sidebar { display: block; }
.brand-side { display: none; }

.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  position: relative;
  display: flex; align-items: center;
  min-height: 44px; padding: 0 var(--sp-3);
  color: var(--ink); text-decoration: none; font-weight: 500;
  border-radius: var(--radius-sm);
}
.nav-link:hover { background: var(--bg); color: var(--ink); }
.nav-link.is-active { background: var(--nav-active-bg); color: var(--accent); font-weight: 700; }
.nav-link.is-active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  border-radius: 2px; background: var(--accent);
}
.nav-item-sep { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--line); }

.logout-form { margin: var(--sp-1) 0 0; }
.logout-form .nav-logout {
  width: 100%; justify-content: flex-start; min-height: 44px; padding: 0 var(--sp-3);
  color: var(--muted); font-weight: 500; border-radius: var(--radius-sm);
}
.logout-form .nav-logout:hover { background: var(--bg); color: var(--ink); border-color: transparent; }

.bare-main { min-height: 100vh; display: grid; place-items: center; padding: var(--sp-4); }
.container-narrow { max-width: 26rem; width: 100%; padding: 0; }
.login-card { padding: var(--sp-6) var(--sp-5); }
.stacked input.sr-only {
  position: absolute; width: 1px; height: 1px; min-height: 0; margin: -1px; padding: 0; border: 0; overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
.stacked label.label-tight { margin-bottom: 0; }
.login-card .stacked label.check-line { display: flex; }
.password-row { display: flex; gap: var(--sp-2); align-items: stretch; margin-bottom: var(--sp-4); }
.password-row input { flex: 1 1 auto; min-width: 0; }
.password-toggle { flex: none; min-width: 5.5rem; margin-top: var(--sp-1); }
.password-toggle[hidden] { display: none; }
.brand-mark {
  margin: 0 0 var(--sp-2); font-size: var(--fs-sm); font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent);
}

@media (min-width: 900px) {
  .topbar, .nav-toggle { display: none; }
  .sidebar, .nav-toggle:checked ~ .sidebar {
    display: flex; flex-direction: column;
    position: fixed; top: 0; bottom: 0; left: 0; width: var(--sidebar-w); z-index: 10;
    padding: var(--sp-5) var(--sp-3) var(--sp-4);
    border-bottom: 0; border-right: 1px solid var(--line);
    overflow-y: auto;
  }
  .brand-side { display: block; padding: 0 var(--sp-3) var(--sp-5); }
  .nav { flex: 1; display: flex; flex-direction: column; }
  .logout-form { margin-top: auto; }
  .main { margin-left: var(--sidebar-w); }
  .container { padding: var(--sp-6) var(--sp-6) 48px; }
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-3) var(--sp-4);
  margin: 0 0 var(--sp-5);
}
.page-header h1 { margin: 0; }
.page-subtitle { margin: var(--sp-1) 0 0; color: var(--muted); font-size: var(--fs-base); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); }

.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--sp-2); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); }

/* ---------- Typographie ---------- */

h1 {
  font-size: var(--fs-xl);
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 var(--sp-4);
}
h2 { font-size: var(--fs-md); line-height: 1.3; margin: 0 0 var(--sp-3); }
h3 {
  font-size: var(--fs-sm);
  margin: var(--sp-4) 0 var(--sp-2);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
p { margin: 0 0 var(--sp-3); }

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

.muted { color: var(--muted); font-size: var(--fs-sm); }
.tabular, .stat-value, .kpi-value, .num { font-variant-numeric: tabular-nums; }
.num { text-align: right; }

/* ---------- Cartes ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--sp-5);
  margin-bottom: var(--sp-5);
}
.card > :last-child { margin-bottom: 0; }
.card > h2:first-child, .card > h1:first-child { margin-top: 0; }
.card-header {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: var(--sp-2) var(--sp-4); margin: 0 0 var(--sp-3);
}
.card-header h2 { margin: 0; }

details.card summary {
  cursor: pointer; min-height: var(--touch); display: flex; align-items: center; gap: var(--sp-3);
  list-style: none;
}
details.card summary::-webkit-details-marker { display: none; }
details.card summary::before {
  content: "+"; flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border: 1px solid var(--line-strong); border-radius: var(--radius-pill);
  font-weight: 700; line-height: 1; color: var(--accent); background: var(--surface);
}
details.card[open] > summary::before { content: "\2212"; }
details.card summary:hover::before { background: var(--accent-soft); }
details.card[open] summary { margin-bottom: var(--sp-3); }

/* ---------- Tableaux ---------- */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.table-wrap:focus-visible { outline-offset: -2px; }

table.data-table { width: 100%; border-collapse: collapse; }
table.data-table th {
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 600;
  font-variant-caps: all-small-caps;
  text-transform: lowercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--line-strong);
  padding: var(--sp-2) var(--sp-4) var(--sp-2) 0;
  white-space: nowrap;
}
table.data-table td {
  padding: var(--sp-3) var(--sp-4) var(--sp-3) 0;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover td { background: var(--accent-soft); }
table.data-table th:last-child, table.data-table td:last-child { padding-right: 0; }
table.data-table th.num, table.data-table td.num { text-align: right; }
table.data-table.wide, .table-wrap.wide > table.data-table { min-width: 44rem; }

/* ---------- Étiquettes de statut ---------- */

.chip, .pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.4;
  padding: 2px var(--sp-3);
  border-radius: var(--radius-pill);
  white-space: nowrap;
  color: var(--chip-new-fg);
  background: var(--chip-new-bg);
}
.chip[data-status="active"], .chip-info, .pill[data-status="active"],
.pill[data-status="running"], .pill[data-status="stepping"] {
  color: var(--chip-info-fg); background: var(--chip-info-bg);
}
.chip[data-status="replied"], .chip-warning, .pill[data-status="replied"] {
  color: var(--chip-warning-fg); background: var(--chip-warning-bg);
}
.chip[data-status="completed"], .chip-success, .pill[data-status="completed"],
.pill[data-status="done"] {
  color: var(--chip-success-fg); background: var(--chip-success-bg);
}
.chip[data-status="stopped"], .chip-danger, .pill[data-status="stopped"],
.pill[data-status="error"] {
  color: var(--chip-danger-fg); background: var(--chip-danger-bg);
}
.chip[data-status="new"], .chip-muted { color: var(--chip-muted-fg); background: var(--chip-muted-bg); }

/* ---------- Boutons ---------- */

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--touch);
  padding: var(--sp-2) var(--sp-4);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
button:hover, .btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
button:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--accent); }
button.secondary, .btn-secondary {
  background: var(--surface); color: var(--accent); border-color: var(--accent);
}
button.secondary:hover, .btn-secondary:hover { background: var(--accent-soft); color: var(--accent-hover); }
.btn-ghost {
  background: transparent; color: var(--accent); border-color: transparent;
}
.btn-ghost:hover { background: var(--accent-soft); color: var(--accent-hover); border-color: transparent; }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--chip-danger-bg); color: var(--chip-danger-fg); border-color: var(--danger); }
.btn-sm { min-height: 32px; padding: var(--sp-1) var(--sp-3); font-size: var(--fs-sm); }

button.link-btn {
  background: none; color: var(--accent); border: 0; padding: 0; min-height: 0;
  font-size: var(--fs-sm); font-weight: 500; text-decoration: underline;
}
button.link-btn:hover { background: none; color: var(--accent-hover); }

/* ---------- Formulaires ---------- */

.stacked label, .field {
  display: block;
  margin-bottom: var(--sp-4);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
}
.stacked input, .stacked select, .stacked textarea, .field input, .field select, .field textarea,
.filters input[type="text"], .filters select {
  display: block;
  width: 100%;
  min-height: var(--touch);
  margin-top: var(--sp-1);
  padding: var(--sp-2) var(--sp-3);
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}
.stacked input[type="checkbox"], .stacked input[type="radio"] { display: inline-block; width: auto; min-height: 0; }
.stacked textarea, .field textarea { resize: vertical; min-height: 5.5rem; }
.stacked input:hover, .stacked select:hover, .stacked textarea:hover { border-color: var(--muted); }
.stacked input:focus-visible, .stacked select:focus-visible, .stacked textarea:focus-visible,
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible,
.filters input:focus-visible, .filters select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--focus);
}
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: var(--danger);
}
.field-hint { display: block; margin-top: var(--sp-1); font-size: var(--fs-sm); font-weight: 400; color: var(--muted); }
.field-error { display: block; margin-top: var(--sp-1); font-size: var(--fs-sm); font-weight: 600; color: var(--danger); }
.form-grid { display: grid; gap: 0 var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); align-items: center; margin-top: var(--sp-2); }

fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.plain:disabled { opacity: 0.55; }

.error {
  color: var(--danger);
  font-size: var(--fs-base);
  font-weight: 600;
}
p.error:not(:empty) {
  background: var(--chip-danger-bg);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: var(--sp-2) var(--sp-3);
  color: var(--chip-danger-fg);
}

.ok { color: var(--success); font-weight: 600; }

.notice { border-left: 4px solid var(--success); }
.notice-info {
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
}

/* ---------- Chiffres clés ---------- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  gap: var(--sp-4) var(--sp-5);
}
.stat { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.stat-value { font-size: var(--fs-kpi); font-weight: 700; line-height: 1.1; letter-spacing: -0.01em; }
.stat-label {
  order: -1;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 0;
}
.kpi-label {
  font-size: var(--fs-xs); font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.kpi-value { font-size: var(--fs-kpi); font-weight: 700; line-height: 1.1; letter-spacing: -0.01em; }
.kpi-hint { font-size: var(--fs-sm); color: var(--muted); }
.kpi .sparkline { margin-top: var(--sp-2); }

.progress {
  position: relative;
  height: 10px;
  background: var(--chip-muted-bg);
  border-radius: var(--radius-pill);
  overflow: visible;
}
.progress-bar {
  height: 100%;
  min-width: 2px;
  max-width: 100%;
  background: var(--status-active);
  border-radius: var(--radius-pill);
}
.progress[data-state="ahead"] .progress-bar { background: var(--success); }
.progress[data-state="on_track"] .progress-bar { background: var(--status-active); }
.progress[data-state="behind"] .progress-bar { background: var(--warning); }
.progress[data-state="no_target"] .progress-bar { background: var(--status-new); }
.progress-mark {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: var(--ink);
}

.sparkline { display: block; width: 100%; height: 40px; }
.sparkline polyline, .sparkline path.line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sparkline .area { fill: var(--accent-soft); stroke: none; }

.callout {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-3);
  color: var(--ink);
}
.callout-title { font-weight: 700; margin: 0 0 var(--sp-1); }
.callout-urgent { border-left-color: var(--danger); background: var(--chip-danger-bg); }
.callout-note, .callout-warning { border-left-color: var(--warning); background: var(--chip-warning-bg); }
.callout-info { border-left-color: var(--accent); background: var(--accent-soft); }
.callout-success { border-left-color: var(--success); background: var(--chip-success-bg); }

.empty-state {
  text-align: center;
  padding: var(--sp-6) var(--sp-4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}
.empty-state strong { display: block; color: var(--ink); font-size: var(--fs-md); margin-bottom: var(--sp-1); }
.empty-state p { margin: 0 auto var(--sp-3); max-width: 32rem; }
.empty-state > :last-child { margin-bottom: 0; }

/* ---------- Pages spécifiques ---------- */

.messages { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.messages li { padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); max-width: 80%; overflow-wrap: anywhere; }
.messages li.sent { background: var(--accent); color: var(--accent-ink); align-self: flex-end; border-bottom-right-radius: var(--sp-1); }
.messages li.received {
  background: var(--surface); border: 1px solid var(--line-strong); align-self: flex-start;
  border-bottom-left-radius: var(--sp-1);
}

.enrichment-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--sp-3);
  margin: 0 0 var(--sp-3);
  max-height: 400px;
  overflow-y: auto;
}

.discovery-table td { vertical-align: top; font-size: var(--fs-sm); }
.discovery-table .muted-row { opacity: 0.6; }
.discovery-table .contact { font-size: var(--fs-xs); color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: var(--sp-4); align-items: flex-end; padding: var(--sp-4) var(--sp-5); }
.filters label { font-size: var(--fs-sm); font-weight: 600; display: flex; flex-direction: column; gap: var(--sp-1); }
.filters label.inline { flex-direction: row; align-items: center; gap: var(--sp-2); min-height: var(--touch); font-weight: 500; }
.filters input[type="text"], .filters select { width: auto; min-width: 11rem; margin-top: 0; }

.tabs { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: 0 0 var(--sp-4); }
.tabs .tab {
  display: inline-flex; align-items: center; min-height: var(--touch);
  text-decoration: none; padding: var(--sp-1) var(--sp-4); border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill); font-size: var(--fs-sm); font-weight: 500;
  color: var(--ink); background: var(--surface);
}
.tabs .tab:hover { background: var(--accent-soft); }
.tabs .tab.current { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.search-label { font-size: var(--fs-xs); }
.pager { text-align: center; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr));
  gap: var(--sp-5);
  margin-bottom: var(--sp-5);
}
.grid-2 > .card { margin-bottom: 0; }
.grid-2 > .card .empty-state { padding: var(--sp-5) var(--sp-4); }

.breadcrumb { margin: 0 0 var(--sp-3); font-size: var(--fs-sm); }
.breadcrumb a { text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

.card > .page-header { margin-bottom: var(--sp-4); }
.card > .page-header h1 { overflow-wrap: anywhere; }

.details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: var(--sp-3) var(--sp-5);
  margin: 0 0 var(--sp-3);
}
.details > div { min-width: 0; }
.details dt {
  font-size: var(--fs-xs); font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px;
}
.details dd { margin: 0; overflow-wrap: anywhere; }

.step-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0 var(--sp-4);
  padding: var(--sp-3) var(--sp-4) var(--sp-3);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.step-row label { display: block; margin-bottom: var(--sp-3); font-size: var(--fs-sm); font-weight: 600; }
.step-row label[hidden], .step-row [hidden] { display: none; }
.step-row input, .step-row select, .step-row textarea {
  display: block; width: 100%; min-height: var(--touch); margin-top: var(--sp-1);
  padding: var(--sp-2) var(--sp-3); font: inherit; font-weight: 400; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
.step-row textarea { resize: vertical; }
.step-row input:focus-visible, .step-row select:focus-visible, .step-row textarea:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus);
}
.step-wide { grid-column: 1 / -1; }
.step-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

/* Étapes d'une séquence (page Séquences) */
.step-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.step-card { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); padding: var(--sp-3) var(--sp-4); }
.step-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-2); }
.step-index {
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; flex: none;
  border-radius: var(--radius-pill); background: var(--accent); color: var(--accent-ink); font-size: var(--fs-xs); font-weight: 700;
}
.step-timing { margin: var(--sp-1) 0 var(--sp-2); color: var(--muted); font-size: var(--fs-sm); }
.step-line { margin: 0 0 var(--sp-1); overflow-wrap: anywhere; }
.template-text { margin: 0 0 var(--sp-2); white-space: pre-wrap; overflow-wrap: anywhere; max-width: 70ch; }
.template-preview {
  margin: var(--sp-2) 0; padding: var(--sp-3) var(--sp-4); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm); overflow-wrap: anywhere;
}
.step-row .template-preview { white-space: pre-wrap; }  /* aperçu écrit par le script : retours à la ligne conservés */
.template-preview > p { margin: 0 0 var(--sp-2); }
.template-preview > :last-child { margin-bottom: 0; }
.step-more { margin-top: var(--sp-1); border-top: 1px solid var(--line); }
.step-more > summary, .more-examples > summary {
  cursor: pointer; min-height: var(--touch); display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-sm); font-weight: 600; color: var(--accent); list-style: none;
}
.step-more > summary::-webkit-details-marker, .more-examples > summary::-webkit-details-marker { display: none; }
.step-more > summary::before, .more-examples > summary::before { content: "+"; width: 1em; text-align: center; font-weight: 700; }
.step-more[open] > summary::before, .more-examples[open] > summary::before { content: "\2212"; }
.step-more > summary:hover, .more-examples > summary:hover { color: var(--accent-hover); text-decoration: underline; }
.step-edit { margin-top: var(--sp-2); }
.run-title { margin-bottom: var(--sp-1); }
.chip + .chip, .pill + .chip { margin-left: var(--sp-1); }

/* ---------- Graphiques SVG (rendus côté serveur, voir app/charts.py) ---------- */

.chart { display: block; width: 100%; max-width: 30rem; height: auto; overflow: visible; }
.chart text { font-family: var(--font); font-size: 13px; fill: var(--ink); }
.chart .chart-value { fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart-track { fill: var(--chip-muted-bg); }
.chart-bar { fill: var(--accent); }
.chart-mark { stroke: var(--ink); stroke-width: 2; }
.chart-progress { max-width: 100%; }
.sparkline .chart-baseline, .chart-baseline { stroke: var(--line-strong); stroke-width: 1; }
.sparkline polyline { vector-effect: non-scaling-stroke; }

.section-title { margin: 0 0 var(--sp-3); }
.nowrap { white-space: nowrap; }
.kpi-link { margin-top: var(--sp-1); font-size: var(--fs-sm); font-weight: 600; }

/* Recommandations */
.reco-list { list-style: none; margin: 0 0 var(--sp-5); padding: 0; }
.reco-list .callout-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-2); }
.reco-list .chip { background: var(--surface); border: 1px solid currentColor; }
@media (max-width: 599px) {
  .reco-list .callout-title { flex-direction: column; align-items: flex-start; gap: var(--sp-1); }
}
.reco-evidence { margin: 0 0 var(--sp-2); font-size: var(--fs-sm); color: var(--muted); }
.callout-urgent .reco-evidence, .callout-note .reco-evidence { color: var(--ink); }

/* Bilan de Claude : texte brut, retours à la ligne conservés */
.insight-meta { margin: 0 0 var(--sp-2); font-size: var(--fs-sm); color: var(--muted); }
.insight-text { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 70ch; line-height: 1.55; }
.insight-source { margin: var(--sp-3) 0 0; font-size: var(--fs-sm); color: var(--muted); }

/* « À faire maintenant » */
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-item {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-4);
  padding: var(--sp-3) 0; border-bottom: 1px solid var(--line);
}
.todo-item:first-child { padding-top: 0; }
.todo-item:last-child { border-bottom: 0; padding-bottom: 0; }
.todo-count {
  min-width: 3rem; text-align: right; font-size: var(--fs-lg); font-weight: 700;
  line-height: 1.2; font-variant-numeric: tabular-nums;
}
.todo-label { flex: 1 1 10rem; font-weight: 600; }

/* Page Statistiques */
.funnel-layout {
  display: grid; gap: var(--sp-5); align-items: start;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
}
.funnel-chart { min-width: 0; }
.trend-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }
.trend-grid .kpi { background: var(--bg); box-shadow: none; }
.info-list, .plain-list { margin: var(--sp-4) 0 0; padding-left: var(--sp-5); }
.plain-list li { margin-bottom: var(--sp-1); }
.gauge-cell { width: 45%; min-width: 7rem; }
.gauge-cell .progress { height: 8px; }

/* En-tête de ligne d'un tableau : lisible comme une cellule, pas comme un titre de colonne. */
table.data-table tbody th.row-label {
  font-variant-caps: normal; text-transform: none; letter-spacing: normal; font-size: inherit;
  font-weight: 600; color: var(--ink); white-space: normal;
  padding: var(--sp-3) var(--sp-4) var(--sp-3) 0; border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data-table tbody tr:last-child th.row-label { border-bottom: none; }
table.data-table tbody tr:hover th.row-label { background: var(--accent-soft); }
table.data-table .unit { font-weight: 400; }
/* Message « pas assez de données » : sous le libellé sur téléphone, dans la ligne sur grand écran. */
.row-note { display: block; margin-top: var(--sp-1); font-weight: 400; }
.row-gap-note { display: none; }
@media (min-width: 640px) {
  .row-note { display: none; }
  .row-gap-note { display: inline; }
}
/* Ligne sous le volume minimal : grisée par la couleur (contraste conservé), jamais par l'opacité. */
table.data-table tr.row-muted th.row-label, table.data-table tr.row-muted td { color: var(--muted); font-weight: 400; }
table.data-table tr.row-muted th.row-label { font-weight: 600; }

/* Messages affichés une fois après une action (voir base.html) */
.flash {
  margin: 0 0 var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-left: 4px solid var(--success);
  border-radius: var(--radius-sm);
  background: var(--chip-success-bg);
  color: var(--chip-success-fg);
  font-weight: 600;
}
.flash-error { border-left-color: var(--danger); background: var(--chip-danger-bg); color: var(--chip-danger-fg); }

/* Saisie des affaires : formulaires, suppression en ligne, ajout rapide repliable */
.inline-form { display: inline; margin: 0; }
.outcome-form .form-grid { margin-bottom: var(--sp-1); }
.quick-add { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); align-items: start; }
/* Un bloc ouvert prend toute la largeur : le formulaire reste lisible. */
.quick-add:has(> details[open]) { grid-template-columns: 1fr; }
.quick-add-item { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); }
.quick-add-item > summary {
  display: flex; align-items: center; min-height: var(--touch); padding: var(--sp-2) var(--sp-4);
  font-weight: 600; color: var(--accent); cursor: pointer; border-radius: var(--radius-sm);
}
.quick-add-item > summary:hover { background: var(--accent-soft); }
.quick-add-item > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.quick-add-item[open] > summary { border-bottom: 1px solid var(--line); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.quick-add-item > .outcome-form { padding: var(--sp-4); margin: 0; }

/* Bandeau d'objectifs du mois (dashboard) */
.goal-card { gap: var(--sp-2); align-items: flex-start; }
.goal-card .chip { align-self: flex-start; }
.goal-figures { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--sp-1); }
.goal-card .kpi-value { font-size: 1.5rem; }
.goal-target { font-size: var(--fs-md); font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.goal-card .chart-progress { margin-top: var(--sp-1); }
.goal-card[data-state="ahead"] .chart-bar { fill: var(--success); }
.goal-card[data-state="behind"] .chart-bar { fill: var(--warning); }
.quick-add-card { margin-top: var(--sp-4); }
.quick-add-title { margin-top: 0; }

/* Réglages : un bloc par mois */
.goal-fieldset { margin-bottom: var(--sp-5); }
.goal-fieldset .form-grid { grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }
.fieldset-title {
  padding: 0; margin: 0 0 var(--sp-3); font-size: var(--fs-sm); font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* Page Style : exemples supplémentaires repliés */
.more-examples { margin-top: var(--sp-2); }

/* ---------- Mobile ---------- */

@media (max-width: 899px) {
  .container { padding: var(--sp-4) var(--sp-4) var(--sp-6); }
  .card { padding: var(--sp-4); }
  h1 { font-size: var(--fs-lg); }
  .stat-value, .kpi-value { font-size: 1.75rem; }
  /* Chiffres clés sur deux colonnes : tout le résumé tient avant « À faire maintenant ». */
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
  .kpi { padding: var(--sp-3) var(--sp-4); }
  .kpi-grid .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .messages li { max-width: 92%; }
  /* 16 px : évite le zoom automatique de iOS sur les champs. */
  .stacked input, .stacked select, .stacked textarea, .field input, .field select, .field textarea,
  .filters input[type="text"], .filters select { font-size: 1rem; }
  .filters input[type="text"], .filters select { width: 100%; }
  .filters label { flex: 1 1 100%; }
  button.link-btn { min-height: var(--touch); padding: 0 var(--sp-2); }
  .btn-sm { min-height: var(--touch); }
  .step-row { grid-template-columns: 1fr; }
  .step-row input, .step-row select, .step-row textarea { font-size: 1rem; }
}

/* Faits sourcés d'une entreprise */
.fact-list { list-style: none; margin: 0 0 var(--sp-3); padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.fact-list li { padding-left: var(--sp-3); border-left: 3px solid var(--line-strong); overflow-wrap: anywhere; }
.fact-text { display: block; }
.fact-source { display: block; font-size: var(--fs-sm); color: var(--muted); }
.fact-meta { font-size: var(--fs-sm); margin-bottom: 0; }

/* Brouillons (liste /drafts et fiche prospect) */
.draft-list, .due-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.draft-item, .due-item { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); padding: var(--sp-3) var(--sp-4); }
.draft-head, .due-item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2) var(--sp-4); }
.draft-who, .due-what { min-width: 0; overflow-wrap: anywhere; }
.draft-meta { margin: var(--sp-1) 0 0; }
.draft-subject { margin: var(--sp-3) 0 var(--sp-2); overflow-wrap: anywhere; }
.draft-body { margin: var(--sp-2) 0; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 70ch; }
.due-item .inline-form { margin: 0; }
.cluster > .chip + .chip { margin-left: 0; }  /* l'espacement vient de l'écart du groupe, y compris à la ligne */

/* ---------- À faire aujourd'hui ---------- */

[hidden] { display: none !important; }  /* « Copier le message » reste caché sans JavaScript */

.cap-line { margin: 0 0 var(--sp-4); }
.section-hint { margin: calc(-1 * var(--sp-1)) 0 var(--sp-3); }
.card-header .chip { flex: none; }

/* Sauts vers les sections (cibles de 40 px, compteurs en toutes lettres pour les lecteurs d'écran) */
.jump { margin: 0 0 var(--sp-5); }
.jump-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.jump-list a {
  display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--touch); padding: 0 var(--sp-3);
  border: 1px solid var(--line-strong); border-radius: var(--radius-pill); background: var(--surface);
  color: var(--ink); font-weight: 600; font-size: var(--fs-sm); text-decoration: none;
}
.jump-list a:hover { background: var(--accent-soft); color: var(--accent-hover); }

.draft-card { display: block; }
.draft-card .draft-head { align-items: flex-start; }
.draft-role { display: block; }
.draft-facts { margin-top: var(--sp-3); }
.draft-facts h3 { margin-top: 0; }
.draft-form { margin-top: var(--sp-3); }
.draft-form label { margin-bottom: var(--sp-1); }
.draft-form textarea { min-height: 7rem; line-height: 1.5; }
.char-count { margin: 0 0 var(--sp-3); font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
.char-count.is-over { color: var(--danger); font-weight: 700; }
.draft-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); }
.draft-actions .inline-form { display: inline-flex; margin: 0; }
.draft-hint, .copy-status { margin: var(--sp-2) 0 0; }
.copy-status { margin: 0; }
.pending-item .draft-actions { justify-content: flex-end; }
.due-item .draft-actions { justify-content: flex-end; }

@media (max-width: 599px) {
  .draft-actions { align-items: stretch; gap: var(--sp-2); }
  .draft-actions .btn, .draft-actions button { flex: 1 1 calc(50% - var(--sp-2)); justify-content: center; text-align: center; }
  /* L'action principale (Marquer envoyé / prêt) prend toute la largeur, les autres se rangent par deux. */
  .draft-actions .btn:not(.btn-secondary):not(.btn-ghost) { flex-basis: 100%; }
  .draft-actions .inline-form { flex: 1 1 calc(50% - var(--sp-2)); }
  .draft-actions .inline-form .btn { width: 100%; justify-content: center; }
  .pending-item .draft-actions, .due-item .draft-actions { justify-content: stretch; width: 100%; }
  .copy-status { flex-basis: 100%; }
}

/* Le message d'une action reste visible quand la page revient sur la carte concernée (ancre) */
.flash-sticky { position: sticky; top: var(--sp-3); z-index: 5; box-shadow: var(--shadow); }
.draft-card, .pending-item { scroll-margin-top: 5rem; }
@media (max-width: 899px) {
  .flash-sticky { top: calc(56px + var(--sp-2)); }
  .draft-card, .pending-item { scroll-margin-top: 9rem; }
}

/* Envoi d'un email : destinataire, aperçu exact du message, historique court */
.draft-to { margin: 0 0 var(--sp-3); }
.send-block { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--line); }
.send-block p { margin: 0; flex: 1 1 14rem; }
.email-preview {
  margin: 0 0 var(--sp-3); padding: var(--sp-3); background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius-sm); white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; line-height: 1.5;
}
.send-summary { display: grid; gap: var(--sp-2); margin: 0 0 var(--sp-4); }
.send-summary > div { display: grid; grid-template-columns: 8rem 1fr; gap: var(--sp-3); }
.send-summary dt { color: var(--muted); font-size: var(--fs-sm); }
.send-summary dd { margin: 0; overflow-wrap: anywhere; }
.sent-title { margin: var(--sp-5) 0 var(--sp-2); font-size: var(--fs-md, 1rem); }
.sent-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.sent-item { display: flex; gap: var(--sp-3); align-items: flex-start; overflow-wrap: anywhere; }
.draft-readonly-label { margin: 0 0 var(--sp-1); }
@media (max-width: 640px) {
  .send-summary > div { grid-template-columns: 1fr; gap: 0; }
  .send-block .btn { flex: 1 1 100%; justify-content: center; text-align: center; }
}

/* Réponses et rebonds : bandeau d'état de la lecture de la boîte mail, extrait d'une réponse */
.sync-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2) var(--sp-4); }
.sync-banner-body { flex: 1 1 18rem; min-width: 0; overflow-wrap: anywhere; }
.sync-banner-body p { margin: 0; }
.sync-banner-body p + p { margin-top: var(--sp-1); }
.sync-banner-action { flex: 0 0 auto; margin: 0; }
.sync-detail { font-size: var(--fs-sm); }
.reply-excerpt {
  margin: var(--sp-2) 0 0; padding: var(--sp-2) var(--sp-3); border-left: 3px solid var(--line); background: var(--surface);
  color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; font-style: normal;
}
.reply-hint { margin: var(--sp-2) 0 0; font-size: var(--fs-sm); }
.reply-item { display: block; scroll-margin-top: 5rem; }
.due-item.reply-item .draft-actions { margin-top: var(--sp-3); justify-content: flex-start; }
@media (max-width: 599px) {
  .sync-banner-action, .sync-banner-action .btn { width: 100%; justify-content: center; }
  .due-item.reply-item .draft-actions { justify-content: stretch; }
}

/* Réglages : sections ancrées, case à cocher, état des variables, aperçu du pied de message */
.settings-section { scroll-margin-top: 5rem; }
.settings-section h3 { margin-top: var(--sp-5); }
.check-line {
  display: flex; align-items: flex-start; gap: var(--sp-3); margin-bottom: var(--sp-4);
  font-size: var(--fs-sm); font-weight: 600; color: var(--ink); cursor: pointer;
}
.stacked .check-line input[type="checkbox"], .stacked .check-line input[type="radio"] { flex: none; width: 1.25rem; height: 1.25rem; margin: 2px 0 0; accent-color: var(--accent); }
.env-status { list-style: none; margin: 0 0 var(--sp-4); padding: 0; display: grid; gap: var(--sp-2); }
.env-name { font-size: var(--fs-sm); }
.settings-from { margin-bottom: var(--sp-3); }
.settings-section .callout { margin: var(--sp-3) 0; }
.settings-section .email-preview { margin-top: var(--sp-2); }
@media (max-width: 640px) {
  .settings-section { scroll-margin-top: 9rem; }
}
