/* X43C Suivi — interface épurée, fond blanc. */
:root {
  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-2: #f1f2f4;
  --bg: #ffffff;
  --bg-soft: #f8f9fa;
  /* Côté X43C : gris (plus de bleu) */
  --x43c: #64748b;
  --x43c-bg: #eef1f5;
  --x43c-ink: #334155;
  --client: #ea580c;
  --client-bg: #fff7ed;
  --client-ink: #c2410c;
  --done: #16a34a;
  --done-bg: #f0fdf4;
  --done-ink: #15803d;
  /* Étapes validées sur la timeline */
  --validated: #8bc248;
  --validated-bg: #eef7e4;
  /* Étape en cours sur la timeline (clignote) */
  --pulse: #cbd5e1;
  --pulse-bg: #eef1f5;
  --neutral-bg: #f3f4f6;
  --danger: #dc2626;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1 { font-size: 24px; line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 14px; font-weight: 650; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.strong { font-weight: 600; text-decoration: none; }
.right { text-align: right; }
.req { color: var(--danger); }

/* En-tête */
.topbar { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 0 24px; height: 60px; display: flex; align-items: center; gap: 32px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.brand img { height: 28px; width: auto; display: block; }
.brand-mark { font-weight: 800; letter-spacing: 0.04em; }
.brand-name { color: var(--muted); }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { text-decoration: none; color: var(--muted); padding: 6px 12px; border-radius: 8px; font-weight: 500; }
.nav a:hover { color: var(--ink); background: var(--bg-soft); }
.nav a.active { color: var(--ink); background: var(--neutral-bg); }
.usermenu { display: flex; align-items: center; gap: 16px; }
.user-chip { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.user-name { font-size: 14px; color: var(--ink-2); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--neutral-bg); color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 650; flex: none;
}
.avatar-x43c { background: var(--x43c-bg); color: var(--x43c-ink); }
.avatar-client { background: var(--client-bg); color: var(--client-ink); }

/* Mise en page */
.container { max-width: 1180px; margin: 0 auto; padding: 32px 24px 64px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.page-head p { margin-top: 6px; }
.eyebrow { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.eyebrow a { text-decoration: none; }
.back { display: inline-block; color: var(--muted); text-decoration: none; font-size: 14px; margin-bottom: 16px; }
.back:hover { color: var(--ink); }
.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px; }
.card.narrow { max-width: 640px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.detail-side { position: sticky; top: 80px; }
aside.detail-side:not(.card) { position: static; }
.stack > * + * { margin-top: 12px; }
.actions { display: flex; gap: 12px; align-items: center; }

/* Boutons et liens */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  color: var(--ink); font: inherit; font-weight: 550; font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.button:hover { background: var(--bg-soft); }
.button.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.button.primary:hover { background: #000; }
.button.wide { width: 100%; }
.link { color: var(--muted); font-size: 14px; }
.link:hover { color: var(--ink); }
.link-button { background: none; border: 0; padding: 0; font: inherit; font-size: 14px; color: var(--muted); cursor: pointer; text-decoration: underline; }
.link-button:hover { color: var(--ink); }
form.inline { display: inline; margin-left: 10px; }

/* Formulaires */
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field-check label { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 14px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  font: inherit; font-size: 14px; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.08); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--ink); }
textarea { resize: vertical; }
.help { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.error { font-size: 13px; color: var(--danger); margin: 6px 0 0; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.field > div > div label { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 14px; margin: 6px 0; }
.field ul { list-style: none; padding: 0; margin: 0; }
.field ul li { margin: 4px 0; }
.field ul li label { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 14px; margin: 0; }
.settings-form h2 { margin-top: 24px; }
.settings-form h2:first-of-type { margin-top: 0; }

/* Messages */
.messages { margin-bottom: 20px; }
.message { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; font-size: 14px; border: 1px solid var(--line); background: var(--bg-soft); }
.message-success { background: var(--done-bg); border-color: #bbf7d0; color: var(--done-ink); }
.message-error { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.message-warning { background: var(--client-bg); border-color: #fed7aa; color: var(--client-ink); }

/* Statuts */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--neutral-bg); color: var(--ink-2); }
.pill-x43c { background: var(--x43c-bg); color: var(--x43c-ink); }
.pill-client { background: var(--client-bg); color: var(--client-ink); }
.pill-fini { background: var(--done-bg); color: var(--done-ink); }
.pill-annule { background: #fef2f2; color: #b91c1c; }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 6px; background: var(--client-bg); color: var(--client-ink); }
.banner { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; font-weight: 550; font-size: 14px; }
.banner-x43c, .banner-neutre { background: var(--x43c-bg); color: var(--x43c-ink); }
.banner-client { background: var(--client-bg); color: var(--client-ink); }
.banner-annule { background: #fef2f2; color: #b91c1c; }
.banner-signal { background: var(--validated-bg); color: #3f6212; }
.tag-signal { background: var(--validated-bg); color: #3f6212; }

/* Onglets et filtres */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { text-decoration: none; color: var(--muted); padding: 8px 14px; margin-bottom: -1px; border-bottom: 2px solid transparent; font-weight: 550; font-size: 14px; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--ink); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 20px; }
.filters input[type=search] { flex: 1 1 220px; width: auto; }
.filters select { width: auto; flex: 0 1 auto; }

/* Choix d'affichage Liste / Timeline */
.tabs-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs-row .tabs { border-bottom: 0; margin-bottom: 0; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.segmented a { text-decoration: none; font-size: 13px; font-weight: 550; color: var(--muted); padding: 5px 12px; }
.segmented a + a { border-left: 1px solid var(--line); }
.segmented a.active { background: var(--neutral-bg); color: var(--ink); }

/* Vue Timeline : une carte par tâche */
.task-cards { display: flex; flex-direction: column; gap: 12px; }
.task-card { display: block; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 12px; text-decoration: none; }
.task-card:hover { background: var(--bg-soft); }
.task-card.needs-me { box-shadow: inset 3px 0 0 var(--ink); }
.task-card-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 14px; font-size: 14px; }
.task-card-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; justify-content: flex-end; font-size: 13px; }
.timeline-compact .step::before { top: 6px; height: 2px; }
.timeline-compact .step .dot { width: 15px; height: 15px; border-width: 2px; margin-bottom: 6px; }
.timeline-compact .step-current .dot { width: 19px; height: 19px; margin-top: -2px; margin-bottom: 4px; }
.timeline-compact .step-label { font-size: 12px; font-weight: 550; line-height: 1.3; }
.timeline-compact .step-current .step-label { font-weight: 700; }
.timeline-compact .step-date { font-size: 11.5px; margin-top: 1px; }

/* Liste des tâches */
.task-list { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.task-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 170px 180px 150px 110px; gap: 16px; align-items: center;
  padding: 14px 18px; border-top: 1px solid var(--line-2); text-decoration: none; font-size: 14px;
}
.task-row:first-child { border-top: 0; }
a.task-row:hover { background: var(--bg-soft); }
.task-row-head { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; background: var(--bg-soft); padding-top: 10px; padding-bottom: 10px; }
.task-row.needs-me { box-shadow: inset 3px 0 0 var(--ink); }
.task-main { display: flex; flex-direction: column; min-width: 0; }
.task-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-client { color: var(--muted); font-size: 13px; }
.task-person { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prio { display: inline-block; width: 16px; height: 16px; line-height: 16px; text-align: center; border-radius: 4px; background: #fef2f2; color: var(--danger); font-size: 11px; font-weight: 800; margin-right: 6px; }
.overdue { color: var(--danger); font-weight: 550; }
.pagination { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 20px; }
.empty { text-align: center; padding: 64px 16px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.empty h1 { color: var(--ink); margin-bottom: 8px; }

/* Timeline façon suivi de colis */
.timeline-card { padding: 28px 22px 22px; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); }
.step { position: relative; text-align: center; padding: 0 6px; }
.step::before {
  content: ""; position: absolute; top: 9px; left: -50%; width: 100%; height: 3px; background: var(--line); z-index: 0;
}
.step:first-child::before { display: none; }
.step .dot {
  position: relative; z-index: 1; display: block; width: 21px; height: 21px; margin: 0 auto 10px;
  border-radius: 50%; background: var(--bg); border: 3px solid var(--line);
}
.step-label { display: block; font-weight: 600; font-size: 14px; color: var(--muted); }
.step-sub { display: block; font-size: 12px; color: var(--muted); }
.step-date { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.step-reached::before, .step-current::before, .step-skipped::before { background: var(--validated); }
.step-reached .dot { background: var(--validated); border-color: var(--validated); }
.step-reached .step-label { color: var(--ink); }
.step-skipped .dot { border-style: dashed; border-color: #cbd5e1; }
.step-current .dot { width: 25px; height: 25px; margin-top: -2px; margin-bottom: 8px; }
.step-current .step-label { color: var(--ink); font-weight: 700; }
/* Étape en cours (sauf Terminée) : pastille gris clair qui clignote doucement. */
.step-current.side-x43c .dot,
.step-current.side-client .dot,
.step-current.side-neutre .dot {
  background: var(--pulse); border-color: var(--pulse); box-shadow: 0 0 0 5px var(--pulse-bg);
  animation: pulse 1.6s ease-in-out infinite;
}
.step-current.side-fini .dot { background: var(--validated); border-color: var(--validated); box-shadow: 0 0 0 5px var(--validated-bg); }
.step-current.side-x43c .step-sub { color: var(--ink-2); }
.step-current.side-client .step-sub { color: var(--client-ink); }
.step-current.side-fini .step-sub { color: var(--done-ink); }
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 5px var(--pulse-bg); }
  50% { opacity: 0.35; box-shadow: 0 0 0 9px var(--pulse-bg); }
}
@media (prefers-reduced-motion: reduce) {
  .step-current .dot { animation: none; }
}

/* Fiche tâche */
.prose p { margin: 0 0 10px; }
.card-action { border-color: #fed7aa; }
.client-action + .client-action { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line-2); }
.client-action label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.comment-form { margin-bottom: 24px; }
.history { list-style: none; margin: 0; padding: 0; }
.event { display: flex; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line-2); }
.event-body { flex: 1; min-width: 0; }
.event-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: 14px; }
.event-head .muted { font-size: 13px; }
.event-body > p { margin: 4px 0 0; font-size: 14px; color: var(--ink-2); }
.event-comment { margin-top: 8px; padding: 10px 14px; background: var(--bg-soft); border-radius: 8px; font-size: 14px; }
.event-comment p:last-child { margin-bottom: 0; }
.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* Tableaux et listes */
.table-card { border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; margin-bottom: 20px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--bg-soft); padding: 10px 16px; font-weight: 600; }
.table td { padding: 12px 16px; border-top: 1px solid var(--line-2); }
.simple-list { list-style: none; padding: 0; margin: 0; }
.simple-list li { padding: 10px 0; border-top: 1px solid var(--line-2); font-size: 14px; }
.simple-list li:first-child { border-top: 0; }
.simple-list a { text-decoration: none; font-weight: 550; margin-right: 6px; }
.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-2); font-size: 14px; }
.people li:first-child { border-top: 0; padding-top: 0; }
.people-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

/* Connexion */
.auth-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; background: var(--bg-soft); }
.auth-card { width: 100%; max-width: 400px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 32px; }
.auth-card h1 { font-size: 20px; margin-bottom: 16px; }
.auth-brand { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; }
.auth-brand img { height: 32px; }
.auth-foot { text-align: center; margin: 20px 0 0; }
.auth-page .messages { width: 100%; max-width: 400px; }

/* Mobile */
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .detail-side { position: static; }
  .user-name { display: none; }
  .task-row { grid-template-columns: 1fr auto; gap: 6px 12px; }
  .task-row-head { display: none; }
  .task-row > span[data-label="Assignée à"], .task-row > span[data-label="Mise à jour"] { display: none; }
  .task-row > span[data-label="Échéance"] { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
}
@media (max-width: 640px) {
  .topbar-inner { gap: 12px; padding: 0 16px; }
  .brand-name { display: none; }
  .nav { gap: 0; overflow-x: auto; }
  .nav a { padding: 6px 8px; font-size: 14px; }
  .container { padding: 20px 16px 48px; }
  .page-head { flex-direction: column; }
  .timeline { grid-template-columns: 1fr; gap: 0; }
  .step { text-align: left; padding: 0 0 18px 36px; }
  .step::before { top: -18px; left: 9px; width: 3px; height: 28px; }
  .step .dot { position: absolute; left: 0; top: 0; margin: 0; }
  .step-current .dot { left: -2px; top: -2px; margin: 0; }
}

/* Vue Timeline sur mobile : la frise reste horizontale, sans libellés */
@media (max-width: 640px) {
  .tabs-row { flex-wrap: wrap; }
  .task-card-head { flex-direction: column; gap: 8px; }
  .task-card-meta { justify-content: flex-start; }
  .timeline-compact { grid-template-columns: repeat(6, 1fr); }
  .timeline-compact .step { text-align: center; padding: 0; }
  .timeline-compact .step::before { top: 6px; left: -50%; width: 100%; height: 2px; }
  .timeline-compact .step .dot { position: relative; left: auto; top: auto; margin: 0 auto 4px; }
  .timeline-compact .step-current .dot { left: auto; top: auto; margin: -2px auto 2px; }
  .timeline-compact .step-label { display: none; }
}
