/* Grafen — démonstration, acte 3 : le plateau des étapes prévisibles et le logiciel sur mesure qui les absorbe.
   Phases (data-phase sur .stage) : shell (coquille), assembling (les cartes arrivent), done (écart et bouton).
   Les zones gardent leur taille d'un bout à l'autre : leur contenu est déjà là, invisible, pour que la page ne bouge pas. */

.stage { --brand: #1f5aa6; display: flex; flex-direction: column; gap: 26px; }

/* --- plateau : les étapes prévisibles telles qu'elles étaient dans la timeline --- */
.tray { position: sticky; top: 76px; z-index: 6; margin: 0 calc(-1 * var(--gutter)); padding: 12px var(--gutter) 14px; background: rgba(var(--bg-rgb), 0.92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.tray__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.tray__count { font-size: 11px; letter-spacing: 0.06em; opacity: 0.5; }
.tray__list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tray__card {
  position: relative; display: flex; flex-direction: column; gap: 6px; min-height: 104px; padding: 12px 14px 12px;
  border: 1px solid rgba(var(--fg-rgb), 0.16); border-radius: 3px; background: rgba(255, 255, 255, 0.7);
  transition: border-color 0.3s, background 0.3s;
}
.tray__num { font-size: 10.5px; opacity: 0.5; }
.tray__action { font-size: 14px; line-height: 1.35; }
.tray__meta { margin-top: auto; font-size: 10px; letter-spacing: 0.03em; opacity: 0.45; }
.tray__done { display: none; align-items: center; gap: 6px; margin-top: auto; font-size: 10.5px; letter-spacing: 0.04em; color: #1f7a45; }
.tray__done svg { width: 12px; height: 12px; }
.tray__card.is-flying { z-index: 30; background: #fff; border-color: var(--brand); box-shadow: 0 18px 40px rgba(18, 38, 46, 0.18); will-change: transform, opacity; }
.tray__card.is-sent { border-style: dashed; background: transparent; }
.tray__card.is-sent > :not(.tray__done) { opacity: 0.22; }
.tray__card.is-sent .tray__meta { display: none; }
.tray__card.is-sent .tray__done { display: inline-flex; animation: rise 0.4s cubic-bezier(0.2, 0.7, 0.2, 1) both; }

/* --- le logiciel : clair, aéré, aux couleurs de l'entreprise --- */
.mk {
  --ink: #101828; --muted: #667085; --line: #eaecf0; --soft: #f7f8fa;
  --ok: #12805c; --ok-bg: #ecfdf3; --warn: #b54708; --warn-bg: #fffaeb; --warn-line: #fedf89;
  color: var(--ink); background: var(--soft); border: 1px solid rgba(var(--fg-rgb), 0.14); border-radius: 16px; overflow: hidden;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 13px; line-height: 1.45;
  box-shadow: 0 40px 100px rgba(18, 38, 46, 0.14), 0 8px 24px rgba(18, 38, 46, 0.06);
}
.mk svg { width: 14px; height: 14px; display: block; flex: none; }
.mk__top { display: flex; align-items: center; gap: 22px; height: 60px; padding: 0 20px; background: #fff; border-bottom: 1px solid var(--line); }
.mk__logo { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.mk__logo b { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: #fff; font-size: 14px; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.15); }
.mk__search { display: flex; align-items: center; gap: 8px; flex: 1; max-width: 340px; height: 36px; padding: 0 10px 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); color: var(--muted); }
.mk__search span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk__search kbd { font-family: inherit; font-size: 11px; padding: 1px 6px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.mk__nav { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--soft); }
.mk__nav span { padding: 6px 12px; border-radius: 7px; color: var(--muted); font-weight: 500; }
.mk__nav .is-on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08); }
.mk__icons { margin-left: auto; display: flex; align-items: center; gap: 14px; color: var(--muted); }
.mk__bell { position: relative; }
.mk__bell svg { width: 18px; height: 18px; }
.mk__bell i { position: absolute; top: -1px; right: -1px; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; }
.mk__avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: color-mix(in srgb, var(--brand) 14%, #fff); color: var(--brand); font-size: 12px; font-weight: 600; }

.mk__body { display: grid; grid-template-columns: 230px minmax(0, 1fr) 270px; align-items: start; }
.mk__side { align-self: stretch; padding: 16px 12px; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.mk__sidehead { display: flex; justify-content: space-between; align-items: center; padding: 0 8px; font-weight: 600; }
.mk__sidehead b { font-size: 11px; padding: 1px 8px; border-radius: 10px; background: var(--soft); color: var(--muted); }
.mk-inbox { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.mk-inbox__item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; padding: 10px; border-radius: 10px; color: var(--muted); }
.mk-inbox__item.is-active { background: color-mix(in srgb, var(--brand) 7%, #fff); color: var(--ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 22%, #fff); }
.mk-inbox__from { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.mk-inbox__time em { font-style: normal; font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 8px; background: var(--brand); color: #fff; vertical-align: 1px; }
.mk-inbox__time { font-size: 11px; }
.mk-inbox__sub { grid-column: 1 / -1; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk__autos { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 10px; background: var(--soft); font-size: 11.5px; color: var(--muted); }
.mk__autos i { width: 8px; height: 8px; border-radius: 50%; background: #12b76a; box-shadow: 0 0 0 3px rgba(18, 183, 106, 0.18); }

.mk__main { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.mk__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.mk__crumb { font-size: 12px; color: var(--muted); }
.mk__crumb span { margin: 0 4px; opacity: 0.5; }
.mk__title { margin-top: 4px; font-size: 20px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; }
.mk__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.mk-chip { font-size: 11.5px; padding: 3px 10px; border-radius: 12px; background: #fff; border: 1px solid var(--line); color: var(--muted); }
.mk-chip--time { color: var(--ok); border-color: #abefc6; background: var(--ok-bg); font-weight: 600; }
.mk__status { flex: none; display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 20px; background: #eff4ff; color: #3538cd; border: 1px solid #c7d7fe; }
.mk__status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse-dot 1.2s ease-in-out infinite; }
@keyframes pulse-dot { 50% { opacity: 0.25; } }
.stage[data-phase='done'] .mk__status { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.stage[data-phase='done'] .mk__status::before { animation: none; }
.mk.is-sent .mk__status { background: var(--ok-bg); color: var(--ok); border-color: #abefc6; }

.mk__grid { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 14px; }
.zone--wide { grid-column: 1 / -1; }

/* --- zones : coquille pointillée → contenu --- */
.zone { position: relative; min-width: 0; padding: 14px 16px 12px; border-radius: 12px; background: #fff; border: 1px solid var(--line); transition: border-color 0.5s, background 0.5s, box-shadow 0.5s; }
.zone__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.zone__title { font-weight: 600; font-size: 13px; }
.zone__meta { font-size: 11.5px; color: var(--muted); }
.zone__skel { position: absolute; left: 16px; right: 16px; top: 46px; display: flex; flex-direction: column; gap: 10px; opacity: 0; pointer-events: none; transition: opacity 0.35s; }
.zone__skel i { display: block; height: 10px; border-radius: 5px; background: linear-gradient(90deg, #eef0f3 0%, #f7f8fa 40%, #eef0f3 80%) 0 0 / 300% 100%; animation: shimmer 1.4s linear infinite; }
.zone__skel i:nth-child(2) { width: 82%; } .zone__skel i:nth-child(3) { width: 64%; } .zone__skel i:nth-child(4) { width: 74%; }
@keyframes shimmer { to { background-position: -150% 0; } }
.zone__body { transition: opacity 0.6s 0.1s, transform 0.6s 0.1s cubic-bezier(0.2, 0.7, 0.2, 1), filter 0.6s 0.1s; }
.zone__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.zone__tags:empty { display: none; }
.zone__tag { display: none; align-items: center; gap: 6px; padding: 3px 9px 3px 7px; border-radius: 10px; background: var(--ok-bg); color: var(--ok); font-size: 11px; }
.zone__tag svg { width: 11px; height: 11px; }
.zone__tag b { font-weight: 600; white-space: nowrap; }
.zone__tag.is-shown { display: inline-flex; animation: tag-pop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.3) both; }
@keyframes tag-pop { from { opacity: 0; transform: scale(0.8) translateY(4px); } to { opacity: 1; transform: none; } }

/* coquille : bordure pointillée, lignes qui scintillent, contenu masqué mais à sa place */
.stage:not([data-phase='done']) .zone:not(.is-filled) { background: #fbfbfc; border-style: dashed; border-color: #d0d5dd; }
.stage:not([data-phase='done']) .zone:not(.is-filled) .zone__title { color: var(--muted); }
.stage:not([data-phase='done']) .zone:not(.is-filled) .zone__meta { visibility: hidden; }
.stage:not([data-phase='done']) .zone:not(.is-filled) .zone__skel { opacity: 1; }
.stage:not([data-phase='done']) .zone:not(.is-filled) .zone__body { opacity: 0; transform: translateY(8px) scale(0.985); filter: blur(6px); }
/* arrivée d'une carte : halo aux couleurs de l'entreprise et balayage lumineux */
.zone.is-landing { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); }
.zone.is-landing::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(100deg, transparent 20%, color-mix(in srgb, var(--brand) 14%, transparent) 50%, transparent 80%) -100% 0 / 200% 100% no-repeat;
  animation: sweep 0.8s ease-out both;
}
@keyframes sweep { to { background-position: 200% 0; } }

/* écart, bouton, durée : n'apparaissent qu'une fois tout assemblé */
.stage:not([data-phase='done']) [data-final] { opacity: 0; transform: translateY(10px); visibility: hidden; }
[data-final] { transition: opacity 0.6s, transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1), visibility 0s; }
.stage[data-phase='done'] .mk__actions { transition-delay: 0.25s; }

/* contenus */
.mk-pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.mk-pill--ok { background: var(--ok-bg); color: var(--ok); }
.mk-doc { display: flex; flex-direction: column; gap: 10px; }
.mk-doc__page { height: 128px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: linear-gradient(#fff, #fcfcfd); display: flex; flex-direction: column; gap: 9px; }
.mk-doc__page b { display: block; width: 40%; height: 8px; border-radius: 3px; background: color-mix(in srgb, var(--brand) 55%, #fff); }
.mk-doc__page span { display: flex; flex-direction: column; gap: 5px; }
.mk-doc__page i { display: block; height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--brand) 18%, #fff); }
.mk-doc__page i:nth-child(odd) { width: 92%; }
.mk-doc__page i.is-flag { background: #fdb022; }
.mk-doc__file strong { display: block; font-weight: 600; font-size: 12.5px; overflow-wrap: anywhere; }
.mk-doc__file small { font-size: 11.5px; color: var(--muted); }
.mk-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.mk-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mk-field__label { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.mk-field__value { position: relative; display: block; padding: 8px 30px 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: color-mix(in srgb, var(--brand) 3%, #fff); font-weight: 500; overflow-wrap: anywhere; }
.mk-field__value i { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); }
.mk-field__value i svg { width: 10px; height: 10px; }
.mk-field__note { font-size: 11px; color: var(--muted); }
.mk-scroll { overflow-x: auto; margin: 0 -16px; }
.mk-table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.mk-table th { text-align: left; font-weight: 500; font-size: 11.5px; color: var(--muted); padding: 8px 16px; background: var(--soft); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); white-space: nowrap; }
.mk-table td { padding: 7px 16px; border-bottom: 1px solid #f2f4f7; }
.mk-table td[data-col='first'] { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.mk-table .is-num { text-align: right; white-space: nowrap; }
.mk-table tr.is-flag td { background: var(--warn-bg); color: #93370d; font-weight: 500; }
.mk-table tr.is-flag td:first-child { box-shadow: inset 3px 0 0 #f79009; }
.mk-table__total td { border-bottom: 0; padding-top: 4px; padding-bottom: 4px; color: var(--muted); text-align: right; }
.mk-table__total:first-child td { padding-top: 10px; }
.mk-table__total.is-last td { color: var(--ink); font-weight: 600; font-size: 13.5px; }
.mk-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.mk-checks li { display: grid; grid-template-columns: 20px 1fr; gap: 9px; align-items: start; }
.mk-ok { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--ok); color: #fff; }
.mk-ok svg { width: 12px; height: 12px; }
.mk-ok--lg { width: 30px; height: 30px; flex: none; }
.mk-ok--lg svg { width: 16px; height: 16px; }
.mk-alert { position: relative; align-self: start; min-width: 0; padding: 14px 16px; border-radius: 12px; background: var(--warn-bg); border: 1px solid var(--warn-line); }
.mk-alert__head { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--warn); }
.mk-alert__head svg { width: 17px; height: 17px; }
.mk-alert__text { margin-top: 8px; font-size: 14px; font-weight: 500; color: #7a2e0e; }
.mk-alert__extra { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--warn-line); color: #7a2e0e; animation: rise 0.4s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.mk-alert__extra b { display: inline-block; margin-right: 8px; font-size: 10.5px; letter-spacing: 0.05em; text-transform: uppercase; padding: 2px 7px; border-radius: 5px; background: #fff; color: var(--brand); border: 1px solid color-mix(in srgb, var(--brand) 30%, #fff); }
.mk-mail { display: flex; flex-direction: column; gap: 6px; }
.mk-mail__row { display: grid; grid-template-columns: 52px 1fr; gap: 8px; padding-bottom: 6px; border-bottom: 1px solid #f2f4f7; }
.mk-mail__row span { color: var(--muted); }
.mk-mail__row b { font-weight: 500; }
.mk-mail__text { margin-top: 4px; color: #344054; }
.mk-mail__text p + p { margin-top: 5px; }
.mk-mail__att { display: inline-flex; align-self: flex-start; align-items: center; gap: 6px; margin-top: 6px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; }
.mk-log { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.mk-log li { position: relative; display: flex; flex-direction: column; gap: 1px; font-size: 12.5px; }
.mk-log li::before { content: ''; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid #12b76a; }
.mk-log li.is-warn::before { border-color: #f79009; }
.mk-log time { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }
.mk__rail { padding: 20px 18px 22px 0; display: flex; flex-direction: column; gap: 14px; }
.mk-table__more td { text-align: center; color: var(--muted); font-size: 12px; background: var(--soft); }
.mk__rail .zone { background: #fff; }

/* action humaine */
.mk__actions { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 14px 16px; border-radius: 12px; background: #fff; border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05); }
.mk__hint { color: var(--muted); }
.mk__hint b { color: var(--ink); font-weight: 600; }
.mk__cta { display: inline-flex; align-items: center; gap: 10px; padding: 12px 20px; border-radius: 10px; background: var(--brand); color: #fff; font-weight: 600; font-size: 14px; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.1), inset 0 -2px 0 rgba(0, 0, 0, 0.15); transition: transform 0.2s, filter 0.2s; }
.mk__cta:hover { transform: translateY(-1px); filter: brightness(1.08); color: #fff; }
.mk__cta:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 40%, #fff); outline-offset: 2px; }
.mk__cta[disabled] { background: var(--ok); cursor: default; transform: none; filter: none; }
.stage[data-phase='done'] .mk:not(.is-sent) .mk__cta { animation: cta-call 1.6s 0.9s ease-in-out 2; }
@keyframes cta-call { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--brand) 22%, transparent); } }
.mk__sent { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 12px; background: var(--ok-bg); border: 1px solid #abefc6; color: #054f31; animation: rise 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.mk__sent strong { font-weight: 600; font-size: 14px; }
.mk__undo { margin-left: 14px; font-size: 12.5px; color: var(--ok); border-bottom: 1px solid currentColor; }

@media (max-width: 1240px) {
  .mk__body { grid-template-columns: 210px minmax(0, 1fr); }
  .mk__rail { grid-column: 2; padding: 0 22px 22px; display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .mk__nav { display: none; }
}

@media (max-width: 880px) {
  .stage { gap: 18px; }
  /* mobile : une rangée qui défile de côté, pour ne pas manger l'écran */
  .tray { top: 62px; padding-top: 8px; padding-bottom: 10px; }
  .tray__head { margin-bottom: 8px; }
  .tray__list { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
  .tray__card { flex: 0 0 148px; min-height: 0; padding: 9px 11px; }
  .tray__action { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .tray__action { font-size: 13px; }
  .tray__meta { display: none; }
  .mk { border-radius: 12px; margin: 0 calc(-1 * var(--gutter) + 8px); }
  .mk__top { gap: 12px; height: 54px; padding: 0 14px; }
  .mk__search, .mk__nav { display: none; }
  .mk__body { grid-template-columns: 1fr; }
  .mk__side { border-right: 0; border-bottom: 1px solid var(--line); padding: 10px; }
  .mk-inbox__item:not(.is-active), .mk__autos { display: none; }
  .mk__main { padding: 14px 12px 16px; gap: 12px; }
  .mk__head { flex-direction: column; gap: 10px; }
  .mk__title { font-size: 17px; }
  .mk__grid { grid-template-columns: 1fr; gap: 12px; }
  .mk-fields { grid-template-columns: 1fr; }
  .mk-table td[data-col='first'], .mk-table th[data-col='first'] { display: none; }
  .mk-table td, .mk-table th { padding-left: 8px; padding-right: 8px; }
  .mk-table td:nth-child(2), .mk-table th:nth-child(2) { padding-left: 16px; }
  .mk-table td:last-child, .mk-table th:last-child { padding-right: 16px; }
  .mk__rail { grid-column: 1; padding: 0 12px 16px; display: flex; }
  .mk__actions { flex-direction: column; align-items: stretch; }
  .mk__cta { justify-content: center; }
  .mk__undo { display: block; margin: 8px 0 0; }
}
