:root {
  --bg: #fafaf7;
  --panel: #ffffff;
  --ink: #1a1a1a;
  --ink-soft: #525252;
  --ink-faint: #8a8a8a;
  --line: rgba(0,0,0,0.08);
  --accent: #0f766e;
  --accent-soft: rgba(15,118,110,0.08);
  --ok: #16a34a;
  --warn: #f59e0b;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px; line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 14px 22px;
  display: flex; align-items: center; gap: 24px;
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.logo { font-size: 20px; }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tab {
  background: transparent; border: 0; cursor: pointer; padding: 7px 14px;
  font: 500 13px inherit; color: var(--ink-soft);
  border-radius: 8px; transition: all .12s;
}
.tab:hover { color: var(--ink); background: rgba(0,0,0,0.03); }
.tab.active { color: var(--accent); background: var(--accent-soft); }

main { padding: 24px 22px 60px; max-width: 1100px; margin: 0 auto; }
h2 { font-size: 18px; font-weight: 700; margin: 22px 0 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 14px; }
.section-head h2 { margin: 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 18px; display: flex; flex-direction: column; gap: 4px;
}
.kpi-lbl { font-size: 11px; font-weight: 600; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .04em; }
.kpi-val { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }

.card-list { display: flex; flex-direction: column; gap: 8px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 4px;
  cursor: pointer; transition: border-color .12s, box-shadow .12s;
}
.card:hover { border-color: rgba(0,0,0,0.16); box-shadow: 0 2px 10px -4px rgba(0,0,0,0.06); }
.card .title { font-weight: 600; font-size: 14px; }
.card .meta { color: var(--ink-soft); font-size: 12.5px; display: flex; gap: 10px; flex-wrap: wrap; }
.card .meta .pill { padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 500; }
.card.relance { border-color: rgba(245,158,11,0.5); background: linear-gradient(0deg, rgba(245,158,11,0.04), rgba(245,158,11,0.04)), var(--panel); }
.pill.overdue { background: rgba(245,158,11,0.16); color: #b45309; font-weight: 600; }
.empty { color: var(--ink-faint); padding: 8px 2px; }
.hint { color: var(--ink-faint); font-size: 12.5px; font-weight: 500; }

.search {
  width: 100%; padding: 9px 12px; margin-bottom: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  font: 400 13px inherit; color: var(--ink); outline: none;
}
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border: 0; border-radius: 8px;
  font: 500 13px inherit; cursor: pointer; transition: all .12s;
}
.btn.primary { background: var(--accent); color: white; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn.ghost:hover { background: rgba(0,0,0,0.03); color: var(--ink); }
.btn.danger { background: transparent; color: #b91c1c; border: 1px solid rgba(185,28,28,0.25); }
.btn.danger:hover { background: rgba(185,28,28,0.06); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: grid; place-items: center; padding: 18px; z-index: 50; }
.modal[hidden] { display: none; }
.modal-card { background: var(--panel); border-radius: 14px; padding: 22px; width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.modal-card h3 { margin: 0 0 4px; font-size: 17px; }
.modal-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-soft); font-weight: 500; }
.modal-card input, .modal-card select, .modal-card textarea {
  padding: 8px 11px; border: 1px solid var(--line); border-radius: 7px;
  font: 400 13.5px inherit; color: var(--ink); background: white; outline: none;
}
.modal-card input:focus, .modal-card select:focus, .modal-card textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal-card textarea { resize: vertical; font-family: inherit; }
.modal-card .actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.pipeline { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.pipe-col { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.pipe-col h3 { margin: 0 0 10px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filters .search { flex: 1; min-width: 180px; }
.filters #filter-st { flex: 0 0 auto; width: auto; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row2 label { min-width: 0; }
.ttc-line { font-size: 13px; color: var(--ink-soft); text-align: right; margin: -2px 0 2px; }
.ttc-line strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.linked { display: flex; flex-direction: column; gap: 6px; margin: 4px 0; }
.linked-title { font-size: 12px; font-weight: 600; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .04em; }
.linked-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: 500 12.5px inherit; color: var(--ink); cursor: pointer; }
.linked-row:hover { border-color: rgba(0,0,0,0.16); }
.pipe-amount { font-size: 18px; font-weight: 700; margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.pipe-count { color: var(--ink-soft); font-size: 12px; }
.pill.brouillon { background: rgba(107,114,128,0.15); color: #4b5563; }
.pill.envoye { background: rgba(245,158,11,0.12); color: #b45309; }
.pill.signe, .pill.facture { background: rgba(22,163,74,0.12); color: #16a34a; }
.pill.refuse { background: rgba(220,38,38,0.12); color: #b91c1c; }
.pill.prospect { background: rgba(99,102,241,0.12); color: #4338ca; }
.pill.encours { background: rgba(245,158,11,0.12); color: #b45309; }
.pill.livre { background: rgba(22,163,74,0.12); color: #16a34a; }
.pill.archive { background: rgba(107,114,128,0.15); color: #4b5563; }
