/* Section Marquages : liste par grille, planche des zones, détail, calculateur, grille tarifaire. Jetons dans app.css. */

.mk { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.mk [hidden] { display: none !important; }

/* ---------- Réglage de référence ---------- */

.mk-settings {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px;
  padding: 0 0 12px; border-bottom: 1px solid var(--sheet-rule, var(--rule));
}
.mk-settings-title { color: var(--ink); align-self: center; }
.mk-settings .select { min-width: 140px; }
.mk-reference-note { margin: -4px 0 0; }

/* ---------- Liste par grille ---------- */

.mk-list-head, .mk-row {
  display: grid; gap: 12px; align-items: start;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 2.2fr) 100px 150px 130px minmax(110px, .6fr);
}
.mk-list-head { padding: 0 12px; align-items: end; }
.mk-list-head > * { white-space: normal; line-height: 1.25; }
.mk-list-head .num { text-align: right; }
.mk-list {
  display: flex; flex-direction: column; min-width: 0;
  border-top: 1px solid var(--rule-strong); border-bottom: 1px solid var(--rule-strong);
}
/* Une grille par ligne, séparées d'un filet ; la ligne ouverte prend la teinte du feuillet et un filet à sa couleur. */
.mk-grid { min-width: 0; }
.mk-grid + .mk-grid { border-top: 1px solid var(--rule); }
.mk-grid.is-open { outline: 1px solid var(--cyan); outline-offset: -1px; position: relative; z-index: 1; }
.mk-grid.is-open > .mk-row { background: var(--cyan-pale); }
.mk-row { padding: 10px 12px; cursor: pointer; }
.mk-row:hover { background: var(--hover); }
.mk-cell { min-width: 0; overflow-wrap: anywhere; }
.mk-toggle {
  display: inline-flex; gap: 6px; align-items: baseline; background: none; border: 0; padding: 0;
  color: var(--ink); cursor: pointer; text-align: left;
}
.mk-toggle { align-items: center; }
.mk-caret { color: var(--cyan-deep); display: inline-flex; }
.mk-caret .icon { width: 16px; height: 16px; transition: transform .18s var(--ease-out); }
.mk-toggle[aria-expanded="true"] .mk-caret .icon { transform: rotate(90deg); }
.mk-code { font-size: var(--fs-xs); color: var(--text); }
code.mk-code { font-family: var(--font-mono); }
.mk-code.is-label { font-size: var(--fs-sm); }
.mk-title-code { margin-left: 8px; font-weight: 400; white-space: nowrap; }
.mk-colors { white-space: nowrap; }
.mk-places { display: flex; flex-wrap: wrap; gap: 6px; }
.mk-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 2px; max-width: 100%;
  border: 1px solid var(--rule-strong); border-radius: 999px; background: var(--surface); cursor: pointer; font-size: var(--fs-sm);
}
.mk-chip:hover { border-color: var(--ink); }
.mk-chip--flat { padding-left: 10px; }
.mk-chip.is-selected { border-color: var(--ink); background: var(--surface); }
.mk-chip-name { color: var(--ink); font-weight: 550; }
.mk-chip-size { font-size: var(--fs-xs); white-space: nowrap; }
.mk-thumb {
  flex: none; width: 28px; height: 28px; border-radius: 50%; overflow: hidden; display: grid; place-items: center;
  background: var(--surface-alt); border: 1px solid var(--rule);
}
.mk-thumb img { width: 100%; height: 100%; object-fit: cover; }
.mk-thumb--none { color: var(--muted); background: var(--surface-alt); border-style: dashed; }
.mk-thumb--none .icon { width: 15px; height: 15px; }
.mk-cost { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.mk-cost-value { font-size: var(--fs-md); }
.mk-cost-bar { display: block; width: 100%; max-width: 96px; height: 3px; background: var(--rule); border-radius: 2px; overflow: hidden; }
.mk-cost-bar > span { display: block; height: 100%; background: var(--cyan); }
.mk-badges { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- Planche des zones ---------- */

.mk-board { padding: 0; }
.mk-board > summary { color: var(--ink); }
.mk-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 10px; }
.mk-tile { margin: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.mk-tile-img {
  display: block; height: 110px; border: 1px solid var(--rule); background: var(--surface); overflow: hidden;
}
.mk-tile-img img { width: 100%; height: 100%; object-fit: contain; }
/* Les emplacements sans image : une seule case pointillée rose, comme une case vide du bon. */
.mk-missing {
  grid-column: 1 / -1; display: flex; flex-direction: column; gap: 4px; padding: 10px 12px;
  background: var(--missing-tint); border: 1px dashed var(--rose);
}
.mk-missing-count { color: var(--missing); font-weight: 650; }
.mk-missing-places { margin: 0; line-height: 1.6; }
.mk-tile.is-shared .mk-tile-img { border-color: var(--warning); }
.mk-tile-list { list-style: none; margin: 4px 0 0; padding: 0; font-size: var(--fs-sm); }
.mk-tile.is-shared { grid-column: 1 / -1; flex-direction: row; align-items: flex-start; gap: 16px; }
.mk-tile.is-shared .mk-tile-img { flex: none; width: 150px; }
.mk-tile-summary { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.mk-tile-count { color: var(--ink); font-size: var(--fs-md); }
.mk-tile-names { margin: 0; }
.mk-tile-detail > summary { color: var(--ink); font-size: var(--fs-sm); }
.mk-tile-detail .mk-tile-list { column-width: 220px; column-gap: 20px; margin-top: 6px; }
.mk-link { background: none; border: 0; padding: 0; color: var(--ink); font-weight: 550; cursor: pointer; text-align: left; }
.mk-link:hover { text-decoration: underline; }

/* ---------- Détail ---------- */

.mk-detail-slot:empty { display: none; }
.mk-detail {
  display: flex; flex-direction: column; gap: 16px; padding: 16px 16px 18px;
  border-top: 1px solid var(--cyan); background: var(--surface); min-width: 0;
}
.mk-detail h4 { margin-bottom: 6px; }
/* Le détail ouvert est du papier blanc : la colonne collante de ses tableaux le reste aussi. */
.mk-detail .data-table .sticky-col { background: var(--surface); }
.mk-detail-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.mk-placement, .mk-constraints { min-width: 0; }
.mk-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.mk-chips .chip { padding: 3px 12px; }
.mk-chips .chip .muted { font-size: var(--fs-xs); }
.mk-chips .chip[aria-pressed="true"] .muted { color: #C9D3EE; }
.mk-zone-img { max-height: 240px; width: auto; max-width: 100%; object-fit: contain; border: 1px solid var(--rule); background: var(--surface); }
.mk-zone-link { display: inline-block; }
.mk-constraint-table { width: auto; min-width: 280px; background: var(--surface); }
.mk-constraint-table th { font-weight: 550; color: var(--ink); }
.mk-constraints .facts { margin-top: 10px; }
.mk-notes { margin: 8px 0 0; padding-left: 18px; }
.mk-ids { margin-top: 10px; }
.mk-ids > summary { color: var(--ink); font-size: var(--fs-sm); font-weight: 550; }
.mk-ids .facts { margin-top: 6px; }

/* ---------- Calculateur ---------- */

.mk-calc { border-top: 1px solid var(--rule); padding: 14px 0 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.mk-calc-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.mk-calc-head h4 { margin: 0; }
.mk-calc-fields { display: flex; flex-wrap: wrap; gap: 10px 12px; }
.mk-calc-main { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 20px; }
.mk-calc-fields--main { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); flex: 3 1 940px; min-width: 0; }
.mk-calc-fields--main .field { min-width: 0; }
.mk-calc-fields--main .input { width: 100%; min-width: 0; }
.mk-calc-summary { flex: 1 1 280px; min-width: 0; }
.mk-calc .input--num { width: 110px; }
.mk-calc .input::placeholder { color: var(--muted); font-style: italic; }
.mk-calc .input[aria-invalid="true"], .mk-calc .input.has-api-error { border-color: var(--error); }
.mk-wide { width: 170px; }
.mk-advanced > summary, .mk-raw-block > summary { color: var(--ink); font-weight: 550; }
.mk-advanced .mk-calc-fields { margin-top: 8px; }
.mk-calc-result { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.mk-calc-result > div { display: flex; flex-direction: column; gap: 10px; }
.is-stale { opacity: .55; }
.mk-figures { gap: 8px 28px; padding: 0; }
.mk-lines-block > summary { color: var(--ink); font-weight: 550; }
.mk-total { color: var(--accent-ink); }
.mk-facts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px 20px; }
.mk-lines { width: auto; min-width: 100%; }
.mk-raw { margin: 4px 0 8px; max-height: 280px; overflow: auto; padding: 8px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); font-family: var(--font-mono); font-size: var(--fs-xs); white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Grille tarifaire ---------- */

.mk-pricegrid { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.mk-pricegrid-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.mk-pricegrid-head h4 { margin: 0; }
.mk-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.mk-tabs .chip[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.mk-tabs .chip.is-empty { opacity: .6; }
.mk-tab-hit { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); flex: none; }
.mk-tabs .chip[aria-selected="true"] .mk-tab-hit { background: #7FDDF3; }
.mk-profile { margin: 4px 0; font-size: var(--fs-sm); color: var(--ink); }
.mk-scroll { border-top: 1px solid var(--rule-strong); }
.mk-table { width: auto; min-width: 100%; }
.mk-table td, .mk-table th { white-space: nowrap; }
.mk-table td.num, .mk-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mk-table th.mk-cond { text-align: left; font-weight: 550; color: var(--ink); min-width: 190px; white-space: normal; border-right: 1px solid var(--rule); }
.mk-cond-line + .mk-cond-line { margin-top: 2px; color: var(--muted); font-weight: 400; }
.mk-cond-line { cursor: help; }
.mk-extra {
  margin-left: 3px; padding: 0 3px; border-radius: 3px; background: var(--warning-soft); color: var(--warning-ink);
  font-size: 11px; font-weight: 700; cursor: help;
}
.mk-formula { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--accent-ink); }
.mk-legend { margin: 0; }
.mk-legend-item { margin-right: 10px; white-space: nowrap; }
.mk-fees, .mk-options { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.mk-options { flex-direction: column; align-items: stretch; }
.mk-option { padding: 4px 0; border-top: 1px solid var(--rule); }
.mk-option-prices { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.data-table td.cell-hit.picked { background: var(--accent-soft); }

@media (max-width: 1200px) {
  .mk-list-head { display: none; }
  .mk-row { grid-template-columns: minmax(0, 1.4fr) 108px minmax(0, 1fr) 110px; }
  .mk-places { grid-column: 1 / -1; order: 5; }
  .mk-badges { grid-column: 1 / -1; order: 6; }
  .mk-detail-top { grid-template-columns: minmax(0, 1fr); }
}
.mk-table td.cell-hit.picked::after { inset: 1px; }
.mk-fee { margin: 2px 2px 0 0; white-space: normal; }
.mk-cond .chip { margin: 4px 4px 0 0; }
.mk-bound { white-space: nowrap; }
.mk-option-comment { margin: 2px 0 0; }
