/* Le tableau de bord qu'on manipule (tableau.js). Tout est en em, comme les autres écrans du kit. */
.pilote {
  padding: var(--espace) var(--bord);
  background: var(--papier);
}

.tb {
  margin-top: clamp(2.5rem, 5vw, 4rem);
  border-radius: var(--r);
  background: var(--blanc);
  box-shadow: var(--ombre);
  overflow: hidden;
  font-size: clamp(11px, min(0.9vw, 1.72svh), 18px);
  line-height: 1.35;
}

.tb :is(p, ul) { margin: 0; }
.tb button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
.tb small { font-size: 0.86em; color: var(--gris); }

.tb-barre {
  display: flex;
  align-items: center;
  gap: 1.5em;
  min-height: 4em;
  padding: 0 1.1em 0 0;
  border-bottom: 1px solid var(--u-ligne);
}

.tb-vues {
  display: inline-flex;
  gap: 0.15em;
  margin-inline: auto;
  padding: 0.22em;
  border-radius: var(--u-r2);
  background: var(--u-creux);
}

.tb-vues button {
  padding: 0.35em 1em;
  border: 0;
  border-radius: calc(var(--u-r2) - 0.16em);
  background: none;
  color: var(--gris);
  white-space: nowrap;
  transition: background-color var(--rapide) ease, color var(--rapide) ease;
}

.tb-vues [aria-pressed="true"] {
  background: var(--blanc);
  color: var(--encre);
  font-weight: 600;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--encre) 16%, transparent);
}

.tb-reprise {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.42em 0.8em;
  border: 0;
  border-radius: var(--u-r2);
  background: none;
  box-shadow: inset 0 0 0 1px var(--u-ligne);
  font-weight: 600;
}

.tb-corps {
  position: relative;
  display: grid;
  grid-template:
    "comptes comptes journal" auto
    "etapes etapes journal" minmax(0, 1fr)
    "planning charge journal" auto / minmax(0, 1fr) 14em 17em;
  gap: 1.1em;
  height: 45em;
  padding: 1.3em;
  background: var(--papier);
}

/* ---------- Les comptes ---------- */
.tb-comptes {
  grid-area: comptes;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.1em;
}

.tb-comptes li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0.75em 1.1em;
  border-radius: var(--u-r);
  background: var(--blanc);
  box-shadow: var(--u-leve);
}

.tb-comptes span { color: var(--gris); }
.tb-comptes b { font-size: 1.9em; line-height: 1.1; letter-spacing: -0.03em; }

/* ---------- Les étapes ---------- */
.tb-etapes {
  grid-area: etapes;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.1em;
  min-height: 0;
}

.tb-col {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.55em;
  padding: 0.7em;
  border-radius: var(--u-r);
  background: var(--u-creux);
  transition: background-color var(--rapide) ease;
}

.tb-col.vise { background: color-mix(in srgb, var(--jaune) 42%, var(--papier)); }
.tb-col .u-titre { display: flex; justify-content: space-between; padding: 0 0.35em; }

.tb-col ul {
  display: grid;
  align-content: start;
  gap: 0.5em;
}

.tb-carte {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.7em;
  padding: 0.55em 0.65em;
  border-radius: calc(var(--u-r) - 0.1em);
  background: var(--blanc);
  box-shadow: var(--u-leve);
  transition: box-shadow var(--rapide) ease, rotate var(--moyen) var(--sortie), background-color var(--moyen) ease;
}

.tb-carte > span:nth-child(2) { display: grid; min-width: 0; line-height: 1.3; }
.tb-carte :is(b, small) { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tb-canal { color: var(--gris); }
.tb-carte.neuve .u-av,
.tb-carte.bouge .u-av { background: var(--jaune); }
.tb-carte.bouge { box-shadow: 0 0 0 0.16em var(--jaune), var(--u-leve); }

.tb-suite {
  position: absolute;
  right: 0.35em;
  top: 50%;
  translate: 0 -50%;
  display: grid;
  place-items: center;
  width: 2.1em;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: var(--u-r2);
  background: var(--encre);
  color: var(--blanc) !important;
  opacity: 0;
  transition: opacity var(--rapide) ease;
}

.tb-suite:focus-visible { opacity: 1; }

.tb-carte.tenu,
.tb-bloc.tenu {
  z-index: 5;
  rotate: 2deg;
  cursor: grabbing;
  box-shadow: 0 1.2em 2.4em -0.9em color-mix(in srgb, var(--encre) 55%, transparent);
  pointer-events: none;
}

.geste { cursor: grabbing; user-select: none; -webkit-user-select: none; }

.tb-carte,
.tb-bloc { user-select: none; -webkit-user-select: none; }

/* ---------- La semaine ---------- */
.tb-planning { grid-area: planning; overflow: visible; }

.tb-grille {
  display: grid;
  grid-template-columns: 6.6em repeat(10, minmax(0, 1fr));
  grid-template-rows: auto repeat(3, 3.5em);
  padding: 0 0.6em 0.6em 0;
}

.tb-jour { padding: 0.45em 0.5em; font-size: 0.86em; color: var(--gris); }
.tb-jour b { color: var(--encre); }
.tb-coin { grid-area: 1 / 1; }

.tb-qui {
  grid-column: 1;
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding-left: 1.1em;
}

.tb-case {
  border-top: 1px solid var(--u-ligne);
  border-left: 1px solid transparent;
  transition: background-color var(--rapide) ease;
}

.tb-case[data-tb-case$="0"], .tb-case[data-tb-case$="2"], .tb-case[data-tb-case$="4"],
.tb-case[data-tb-case$="6"], .tb-case[data-tb-case$="8"] { border-left-color: var(--u-ligne); }
.tb-case.vise { background: color-mix(in srgb, var(--jaune) 45%, var(--blanc)); }

.tb-bloc {
  position: relative;
  display: grid;
  align-content: center;
  margin: 0.18em;
  padding: 0.1em 0.45em;
  border-radius: var(--u-r2);
  background: var(--encre);
  color: var(--blanc);
  font-size: 0.86em;
  line-height: 1.2;
  min-width: 0;
  transition: background-color var(--moyen) ease, color var(--moyen) ease;
}

.tb-bloc :is(b, small) { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tb-bloc small { color: inherit; opacity: 0.72; }
.tb-bloc > .ico { display: none; }
.tb-bloc.bouge { background: var(--jaune); color: var(--encre); }
.tb-bloc.fait { background: var(--filet); color: var(--encre); }
.tb-bloc.fait > .ico { display: block; position: absolute; right: 0.35em; top: 0.35em; width: 1em; height: 1em; }

.tb-bloc.fixe {
  background: repeating-linear-gradient(-45deg, var(--u-creux) 0 5px, transparent 5px 10px);
  color: var(--gris);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ---------- La charge ---------- */
.tb-charge { grid-area: charge; }

.tb-barres {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.7em;
  padding: 1em 1.1em 0.8em;
}

.tb-barres > span { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 0.4em; text-align: center; }

.tb-barres i {
  position: relative;
  border-radius: var(--u-r2);
  background: var(--u-creux);
  overflow: hidden;
}

.tb-barres i::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--encre);
  translate: 0 calc((1 - var(--n, 0)) * 100%);
  transition: translate var(--lent) var(--sortie);
}

/* ---------- Le journal et les factures ---------- */
.tb-journal { grid-area: journal; background: var(--encre); color: var(--blanc); }
.tb-journal .u-entete { border-color: var(--filet-encre); }
.tb-journal .mascotte { --m: 2.4em; --coque: var(--blanc); --jaune-part: 66%; --oeil-l: 8%; --oeil-h: 19%; --oeil-x: 35%; }
.tb-journal ul { display: grid; align-content: start; padding: 0.5em 1.1em; overflow: hidden; }
.tb-journal small { color: var(--gris-clair); }

.tb-journal li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.8em;
  padding: 0.7em 0;
  border-bottom: 1px solid var(--filet-encre);
  animation: tb-arrive var(--moyen) var(--sortie);
}

.tb-journal li:last-child { border: 0; }
.tb-journal li > span { display: grid; line-height: 1.3; }
.tb-journal li .ico { width: 2.3em; height: 2.3em; padding: 0.55em; border-radius: 50%; background: var(--filet-encre); }
.tb-journal li:first-child .ico { background: var(--jaune); color: var(--encre); }

@keyframes tb-arrive {
  from { opacity: 0; translate: 0 -0.8em; }
}

.tb-factures { display: none; }

.tb-factures li {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 7em 7em;
  align-items: center;
  gap: 1em;
  min-height: 3.6em;
  padding: 0 1.1em;
  border-bottom: 1px solid var(--u-ligne);
}

.tb-factures li em { justify-self: start; }
.tb-factures li span { color: var(--gris); }
.tb-factures button { padding: 0.4em 0.9em; border: 0; border-radius: var(--u-r2); background: var(--encre); color: var(--blanc); font-weight: 600; }

/* ---------- Les trois vues ---------- */
[data-vue="planning"] { grid-template: "planning journal" minmax(0, 1fr) / minmax(0, 1fr) 17em; }
[data-vue="planning"] .tb-grille { grid-template-rows: auto repeat(3, minmax(3.5em, 1fr)); }
[data-vue="planning"] :is(.tb-comptes, .tb-etapes, .tb-charge) { display: none; }
[data-vue="planning"] .tb-bloc { font-size: 1em; }
[data-vue="factures"] { grid-template: "comptes journal" auto "factures journal" minmax(0, 1fr) / minmax(0, 1fr) 17em; }
[data-vue="factures"] :is(.tb-planning, .tb-etapes, .tb-charge) { display: none; }
[data-vue="factures"] .tb-factures { display: grid; grid-area: factures; }

/* ---------- Le curseur de la démonstration ---------- */
.tb-curseur {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 6;
  width: 1.9em;
  opacity: 0;
  pointer-events: none;
  transition: translate 520ms var(--traverse), opacity 200ms ease;
}

.tb-curseur.la { opacity: 1; }
.tb-curseur svg { display: block; fill: var(--encre); stroke: var(--blanc); stroke-width: 1.6; overflow: visible; filter: drop-shadow(0 2px 4px color-mix(in srgb, var(--encre) 40%, transparent)); }

@media (hover: hover) and (pointer: fine) {
  .tb-carte { cursor: grab; }
  .tb-bloc:not(.fixe) { cursor: grab; }
  .tb-carte:hover { box-shadow: 0 0 0 1px color-mix(in srgb, var(--encre) 18%, transparent), 0 0.8em 1.6em -0.8em color-mix(in srgb, var(--encre) 34%, transparent); }
  .tb-carte:hover .tb-suite { opacity: 1; }
  .tb-vues button:hover { color: var(--encre); }
}

@media (hover: none) {
  .tb-canal { visibility: hidden; }
  .tb-suite { opacity: 1; }
}

/* ---------- Téléphone : les étapes se font glisser, le reste s'empile ---------- */
@media (max-width: 60rem) {
  .tb { font-size: 13px; }
  .tb-barre { flex-wrap: wrap; gap: 0.6em; padding: 0.7em 0.9em; }
  .tb-barre .u-soc { padding: 0; }
  .tb-vues { order: 3; margin: 0; width: 100%; }
  .tb-vues button { flex: 1; padding: 0.5em 0; }
  .tb-reprise { margin-left: auto; }
  .tb-corps,
  [data-vue] { grid-template: none; grid-template-columns: minmax(0, 1fr); height: auto; padding: 0.9em; gap: 0.9em; }
  .tb-corps > * { grid-area: auto !important; }
  .tb-comptes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6em; }
  .tb-comptes li { padding: 0.5em 0.8em; }
  .tb-comptes b { font-size: 1.5em; }
  .tb-etapes { grid-template-columns: repeat(4, 74%); overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; margin-inline: -0.9em; padding-inline: 0.9em; scroll-padding-inline: 0.9em; scrollbar-width: none; }
  .tb-col { scroll-snap-align: start; min-height: 15em; }
  .tb-grille { grid-template-columns: 3.4em repeat(10, minmax(0, 1fr)); }
  .tb-qui { padding-left: 0.8em; }
  .tb-qui b,
  .tb-bloc:not(.fixe) small { display: none; }
  .tb-bloc b { display: none; }
  .tb-bloc { font-size: 0 !important; padding: 0; margin: 2px; border-radius: 6px; } /* trop étroit pour un nom : la couleur suffit */
  .tb-jour { padding: 0.4em 0.2em; }
  .tb-charge { display: none; }
  .tb-journal ul { min-height: 0; }
  .tb-journal li:nth-child(n + 4) { display: none; }
  .tb-factures li { grid-template-columns: minmax(0, 1fr) auto auto; }
  .tb-factures li span { display: none; }
  .tb-curseur { display: none; }
}
