:root {
  --ink: #1d2433;
  --muted: #6b7385;
  --line: #e2e5ec;
  --bg: #f5f6f9;
  --card: #fff;
  --accent: #1f4e79;
  --accent-soft: #e6eef7;
  --late: #b3261e;
  --late-soft: #fdecea;
  --ok: #1e7a4c;
  --radius: 8px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
h3 { font-size: .95rem; margin: 1rem 0 .4rem; }
main { max-width: 1280px; margin: 0 auto; padding: 1.2rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.pre, .t-body { white-space: pre-wrap; word-break: break-word; }

/* En-tête */
.top { display: flex; align-items: center; gap: 1rem; padding: .5rem 1.2rem; background: var(--accent); color: #fff; position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.top a { color: #fff; }
.brand { font-weight: 700; letter-spacing: .05em; }
.top nav { display: flex; gap: .2rem; flex-wrap: wrap; }
.top nav a { padding: .35rem .6rem; border-radius: 6px; opacity: .85; }
.top nav a.on, .top nav a:hover { background: rgba(255,255,255,.15); opacity: 1; text-decoration: none; }
.top .search { margin-left: auto; }
.top .search input { border: 0; border-radius: 6px; padding: .4rem .6rem; width: 220px; }
.menu { position: relative; }
.menu summary { cursor: pointer; list-style: none; padding: .3rem .6rem; font-size: 1.2rem; }
.menu div { position: absolute; right: 0; top: 2.2rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem; min-width: 200px; box-shadow: 0 6px 20px rgba(0,0,0,.1); }
.menu div a, .menu div button { display: block; color: var(--ink); padding: .4rem .6rem; width: 100%; text-align: left; }

/* Blocs */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.card.late { border-color: var(--late); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.layout { display: grid; grid-template-columns: 360px 1fr; gap: 1rem; align-items: start; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem 1rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline { display: inline; }
@media (max-width: 900px) {
  .layout, .grid2 { grid-template-columns: 1fr; }
  .top .search input { width: 140px; }
  main { padding: .8rem; }
}

/* Formulaires */
input, select, textarea { font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: .45rem .6rem; background: #fff; color: var(--ink); max-width: 100%; }
textarea { width: 100%; resize: vertical; }
.form label, label.picker { display: flex; flex-direction: column; gap: .2rem; margin-bottom: .6rem; }
.form label > span, label.picker > span { font-size: .85rem; color: var(--muted); }
.form input, .form select { width: 100%; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: .5rem .9rem; cursor: pointer; font: inherit; display: inline-block; }
.btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.flash.ok { background: #e7f5ee; color: var(--ok); }
.flash.error { background: var(--late-soft); color: var(--late); }
.auth { max-width: 420px; margin: 4rem auto; }
.auth input { width: 100%; }
.auth label { display: flex; flex-direction: column; gap: .2rem; margin-bottom: .8rem; }

/* Sélecteur avec recherche */
.picker { position: relative; }
.picker-list { position: absolute; top: 100%; left: 0; right: 0; z-index: 5; background: #fff; border: 1px solid var(--line); border-radius: 6px; list-style: none; margin: 2px 0 0; padding: .2rem; max-height: 240px; overflow: auto; box-shadow: 0 6px 20px rgba(0,0,0,.08); }
.picker-list li { padding: .35rem .5rem; cursor: pointer; border-radius: 4px; }
.picker-list li:hover, .picker-list li.on { background: var(--accent-soft); }

/* Listes et tableaux */
.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .8rem; color: var(--muted); font-weight: 600; background: #fafbfc; }
.table tr.late td { background: var(--late-soft); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .35rem 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list li.late time, .tasks li.late time { color: var(--late); font-weight: 600; }
.list time { display: inline-block; min-width: 5.5rem; color: var(--muted); }
.props { display: grid; grid-template-columns: auto 1fr; gap: .25rem .8rem; margin: 0; }
.props dt { color: var(--muted); font-size: .85rem; }
.props dd { margin: 0; word-break: break-word; }
.pager { display: flex; gap: 1rem; justify-content: center; margin: 1rem 0; }
.filters-bar { margin-bottom: .8rem; }

/* Groupes */
.seg { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 99px; background: #eef0f4; color: var(--muted); }
.seg-actif { background: #e7f5ee; color: var(--ok); }
.seg-reseau { background: #efe8fb; color: #5b3b9a; }
.seg-dormant { background: #fff4e0; color: #8a5a00; }
.seg-archive { background: #eef0f4; color: #7a8090; }
.chip { display: inline-block; border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: .2rem .7rem; cursor: pointer; font: inherit; font-size: .85rem; color: var(--ink); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.small { padding: .1rem .5rem; font-size: .78rem; }

/* Tableau de bord */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 900px) { .kpis { grid-template-columns: 1fr; } }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; gap: .3rem; }
.kpi-label { font-size: .85rem; color: var(--muted); }
.kpi-value { font-size: 1.6rem; font-weight: 700; }
.kpi-value small { font-size: 1rem; color: var(--muted); font-weight: 400; }
.bar { height: 8px; background: #eef0f4; border-radius: 99px; overflow: hidden; }
.bar div { height: 100%; background: var(--accent); }

/* Tâches */
.tasks { list-style: none; padding: 0; margin: 0 0 .6rem; }
.tasks li { display: flex; gap: .5rem; align-items: baseline; padding: .3rem 0; border-bottom: 1px solid var(--line); }
.tasks li time { margin-left: auto; color: var(--muted); font-size: .85rem; }
.check { width: 1.4rem; height: 1.4rem; border-radius: 50%; border: 1px solid var(--line); background: #fff; cursor: pointer; color: var(--muted); font-size: .8rem; padding: 0; }
.check:hover { background: #e7f5ee; color: var(--ok); border-color: var(--ok); }

/* Pipeline en colonnes */
.board { display: flex; gap: .7rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }
.col { flex: 0 0 240px; background: #eceff4; border-radius: var(--radius); padding: .5rem; min-height: 200px; }
.col header { display: flex; flex-direction: column; padding: .2rem .3rem .5rem; font-size: .9rem; }
.col-won { background: #e3f2ea; }
.col-lost { background: #eeeeee; opacity: .85; }
.col.over { outline: 2px dashed var(--accent); }
.cards { display: flex; flex-direction: column; gap: .5rem; min-height: 60px; }
.kcard { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: .5rem .6rem; cursor: grab; font-size: .9rem; }
.kcard.late { border-left: 3px solid var(--late); }
.kcard.dragging { opacity: .5; }

/* Barre d'étapes */
.stagebar { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 1rem; }
.step { border: 0; background: #e6e9ef; color: var(--muted); padding: .35rem .6rem; font: inherit; font-size: .8rem; cursor: pointer; border-radius: 4px; }
.step.on { background: var(--accent); color: #fff; }
.step.on.step-won { background: var(--ok); }
.step.on.step-lost { background: #777; }

/* Fil chronologique */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 3px solid var(--line); padding: .5rem 0 .7rem .8rem; margin-left: .2rem; }
.timeline li.hidden { display: none; }
.t-head { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; margin-bottom: .2rem; }
.t-head form { margin-left: auto; }
.t-head time { color: var(--muted); font-size: .85rem; }
.t-body { font-size: .92rem; }
.t-body.clamp { max-height: 9em; overflow: hidden; }
.t-body.open { max-height: none; }
.badge { font-size: .72rem; padding: .1rem .45rem; border-radius: 4px; background: #eef0f4; }
.b-note { background: #fff4e0; }
.b-email { background: var(--accent-soft); }
.b-meeting { background: #e7f5ee; }
.b-call { background: #efe8fb; }
.t-note { border-left-color: #f0c36d; }
.t-email { border-left-color: #8fb1d6; }
.t-meeting { border-left-color: #7cc4a0; }
.t-call { border-left-color: #b9a2e0; }
.filters { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .6rem; }
.note-form .row { margin-bottom: .5rem; }
.dictate-wrap { position: relative; margin-bottom: .5rem; }
.dictate { position: absolute; right: .4rem; bottom: .5rem; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; font-size: .8rem; padding: .2rem .5rem; }
.dictate.rec { background: var(--late); color: #fff; border-color: var(--late); }
.log { background: #0f1520; color: #d6e2f0; padding: .8rem; border-radius: 6px; max-height: 420px; overflow: auto; font-size: .82rem; white-space: pre-wrap; }
