/* Générateur SAF — fondation de grue (api_web/saf.py). Chargée par l'établi generateur-saf seul. Les briques communes
   restent celles de la charte et de l'établi compact ; ici, ce qu'elles n'avaient pas : les petits tableaux de la saisie
   (sommets, valeurs de k, jeux de réactions), le plan qui se manipule (js/plan.js), le tableau par k, les positions,
   « Proposer » et sa barre de progression, le bouton d'export. */

/* ------------------------------------------------------------------ la saisie : les petits tableaux */
.sf-tab { display: grid; gap: 5px; margin: 2px 0 4px; }
.sf-x { flex: none; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; color: var(--ink-4); }
.sf-x:hover { background: var(--bg-sunken); color: var(--nok); }
.sf-x svg.i { width: 14px; height: 14px; }
.sf-som { display: grid; grid-template-columns: 18px minmax(0, 1fr) minmax(0, 1fr) 26px; align-items: center; gap: 6px; }
.sf-som .n { font-size: 11px; font-weight: 600; color: var(--ink-3); text-align: right; font-variant-numeric: tabular-nums; }
.sf-som-h { font-size: 11px; color: var(--ink-3); font-style: italic; }
.sf-som-h > span:not(.n) { padding-left: 8px; }
.sf-som > .field, .sf-k > .field, .sf-p > .field { height: 30px; min-width: 0; }
.sf-k { display: grid; grid-template-columns: minmax(0, 1fr) auto 26px; align-items: center; gap: 8px; }
.sf-k .case { margin: 0; white-space: nowrap; }
.sf-pied { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
.sf-pied .btn.sm svg.i { width: 13px; height: 13px; }
.sf-repris { display: flex; align-items: center; gap: 6px; margin-top: 6px; padding: 5px 4px 5px 9px; border-radius: 8px; background: var(--accent-soft);
  font-size: 12px; color: var(--ink-2); }
.sf-repris > span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-jeu { display: grid; grid-template-columns: 18px minmax(0, 1fr) 26px; align-items: center; gap: 5px 6px; padding: 6px 0 2px; border-top: 1px solid var(--line); }
.sf-jeu:first-child, .sf-jeu-h + .sf-jeu { border-top: 0; padding-top: 0; }
.sf-jeu-h { padding: 0; }
.sf-jeu-h > .sf-p { grid-column: 2 / 4; font-size: 11px; font-weight: 600; color: #d9480f; text-align: right; }
.sf-jeu-h > .sf-p > span { padding-right: 7px; }
.sf-jeu > .n { font-size: 12px; font-weight: 700; color: var(--ink-2); text-align: right; }
.sf-jeu > .field.text { height: 28px; min-width: 0; }
.sf-jeu > .sf-p { grid-column: 2 / 4; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.sf-p > .field { padding: 0 6px; }
.sf-p > .field input { text-align: right; }
.sf-num-l { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font-size: 11.5px; color: var(--ink-3); line-height: 1.35; }
.sf-num { width: 96px; height: auto; flex: none; }

/* la grue : le châssis choisi, ce que la bibliothèque dit, les grues enregistrées */
.sf-chassis-b { width: 100%; justify-content: space-between; height: 32px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--panel); font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 6px; }
.sf-chassis-b > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-chassis-b svg.i { width: 14px; height: 14px; flex: none; color: var(--ink-3); }
.sf-chassis-b:hover { border-color: var(--accent); }
.sf-note { font-size: 11.5px; color: var(--ink-3); line-height: 1.4; margin: -2px 0 4px; }
.sf-lu { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--ink-3); padding: 2px 0; }
.sf-lu > b { font-weight: 600; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
.sf-orig { color: inherit; cursor: help; }
.sf-saisi { font-weight: 600; color: var(--accent-hover); }
.sf-pastille { display: inline-flex; align-items: center; gap: 4px; margin-top: 5px; padding: 2px 8px; border-radius: 999px; background: #FEF3C7; color: #92400E;
  font-size: 11px; font-weight: 600; cursor: help; }
.sf-pastille svg.i { width: 12px; height: 12px; }
[data-theme="dark"] .sf-pastille { background: #3A2A0C; color: #FCD34D; }
.sf-grue { display: flex; align-items: center; gap: 4px; }
.sf-grue-b { flex: 1 1 auto; min-width: 0; height: 28px; padding: 0 8px; border-radius: 7px; text-align: left; font-size: 12.5px; font-weight: 500; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-grue-b:hover { background: var(--accent-soft); color: var(--accent-hover); }

/* le sélecteur des châssis : sa recherche */
.pk-cherche { flex: 1 1 100%; height: 30px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 10px; font: inherit; font-size: 12.5px;
  background: var(--panel); color: var(--ink); }
.pk-cherche:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.picker .pk-row[hidden] { display: none; }

/* ------------------------------------------------------------------ le plan : son en-tête, ce qui se manipule */
.sf-ent { align-items: flex-start; gap: 10px 14px; flex-wrap: wrap; }
.sf-vue { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.sf-vue .seg button { height: 28px; padding: 0 9px; font-size: 12px; }
.sf-vue .field.select { height: 28px; min-width: 0; max-width: 210px; }
.sf-vue .field.select select { font-size: 12px; }
.sf-plan { touch-action: pan-x pan-y; }
.sf-plan [data-plan-sec] { cursor: pointer; }
.sf-plan .sf-chassis { cursor: grab; }
.sf-plan .sf-chassis.sf-glisse { cursor: grabbing; }
.sf-plan .sf-chassis:hover .sf-appui { stroke-width: 4; }
.sf-plan .sf-poignee, .sf-plan .sf-sommet { cursor: grab; }
.sf-plan .sf-poignee:hover, .sf-plan .sf-sommet:hover { fill: #FEF3C7; }
.sf-plan .sf-tirer.h { cursor: ew-resize; }
.sf-plan .sf-tirer.v { cursor: ns-resize; }
.sf-plan .sf-tirer:hover, .sf-plan .sf-bord:hover { stroke-opacity: .14; }
.sf-plan .sf-bord { cursor: pointer; }
.sf-plan .sf-fond { cursor: crosshair; }
.sf-plan .sf-clic { cursor: text; }
.sf-plan .sf-clic:hover { text-decoration: underline; }
/* pendant un geste, ce qui ne suit pas l'objet se retire : les bandes, les cotes, la valeur pointée, la carte s'estompe */
.sf-plan.sf-en-geste .sf-bandes, .sf-plan.sf-en-geste .sf-cotes, .sf-plan.sf-en-geste .sf-max { visibility: hidden; }
.sf-plan.sf-en-geste .sf-carte { opacity: .35; }
.sf-plan .sf-etiq { font-family: Inter, system-ui, sans-serif; font-weight: 600; fill: #0D1525; text-anchor: middle; paint-order: stroke; stroke: #fff;
  stroke-linejoin: round; pointer-events: none; }
/* la cote qu'on tape : un champ posé sur elle */
.sf-saisie { position: fixed; z-index: 80; height: 30px; border: 2px solid var(--accent); border-radius: 8px; padding: 0 8px; font: inherit; font-size: 13px;
  font-weight: 600; text-align: center; background: var(--panel); color: var(--ink); box-shadow: var(--shadow-pop); font-variant-numeric: tabular-nums; }
.sf-saisie:focus { outline: none; }

/* ------------------------------------------------------------------ les vérifications */
.sf-tk { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.sf-tk th { text-align: left; font-size: 11px; font-weight: 600; color: var(--ink-3); padding: 2px 6px 5px; white-space: nowrap; }
.sf-tk th small { display: block; font-weight: 500; font-size: 10px; color: var(--ink-4); }
.sf-tk td { padding: 4px 6px; border-top: 1px solid var(--line); }
.sf-tk .n { text-align: right; }
.sf-tk .c { text-align: center; }
.sf-tk tr.vu td { background: var(--accent-soft); }
.sf-tk tr.vu td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.sf-tk .chip { min-width: 46px; justify-content: center; }
.sf-lien { font: inherit; font-weight: 700; color: var(--ink); padding: 2px 6px; margin: -2px -6px; border-radius: 6px; min-width: 30px; text-align: left; }
.sf-lien:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent-hover); }
.sf-scia { display: inline-grid; place-items: center; width: 28px; height: 24px; cursor: pointer; }
.sf-scia input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.sf-moyen { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--ink-3); cursor: help; }
.sf-moyen b { color: var(--ink); font-variant-numeric: tabular-nums; }
.sf-moyen .d { font-size: 11px; color: var(--ink-4); font-variant-numeric: tabular-nums; }
/* (un contrôle qui n'a rien à comparer tient sur sa première ligne : la seconde, vide, ne prend pas de place) */
#resultat .el.vc .l2:has(> .cmp:empty:only-child) { display: none; }
.sf-pos { margin: 10px 10px 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.sf-pos > summary { display: flex; align-items: baseline; gap: 8px; padding: 9px 10px; cursor: pointer; list-style: none; font-size: 12.5px; }
.sf-pos > summary::-webkit-details-marker { display: none; }
.sf-pos > summary > b { color: var(--ink); white-space: nowrap; }
.sf-pos > summary > span { flex: 1 1 auto; min-width: 0; font-size: 11.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-pos > summary > svg.i { flex: none; align-self: center; width: 14px; height: 14px; color: var(--ink-3); transition: transform .15s; }
.sf-pos[open] > summary > svg.i { transform: rotate(180deg); }
.sf-pos[open] > summary { border-bottom: 1px solid var(--line); }
.sf-pos > .sf-cas-l { padding: 4px; }
.sf-detail { display: inline-flex; align-items: center; gap: 5px; margin: 0 6px 6px; padding: 4px 6px; border-radius: 6px; font-size: 11.5px; font-weight: 600;
  color: var(--ink-3); }
.sf-detail:hover { background: var(--bg-sunken); color: var(--ink); }
.sf-detail svg.i { width: 13px; height: 13px; }
.sf-cas-l { display: grid; gap: 1px; }
.sf-cas { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 7px; font: inherit;
  font-size: 12px; text-align: left; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.sf-cas b { color: var(--ink); }
.sf-cas > span:nth-child(2) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-cas:hover { background: var(--bg-sunken); }
.sf-cas.vu { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.sf-cas .chip { min-width: 46px; justify-content: center; }

/* « Proposer » : le bouton, la barre de progression, le tableau */
.sf-prop { margin: 12px 10px 0; padding-top: 10px; border-top: 1px solid var(--line); }
.sf-prop-h { display: flex; align-items: center; gap: 8px; }
.sf-prop-h .btn svg.i { width: 14px; height: 14px; }
.sf-prop-s { flex: 1 1 auto; min-width: 0; font-size: 11px; color: var(--ink-4); line-height: 1.3; }
.sf-prog { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.sf-prog-b { flex: 1 1 auto; height: 6px; border-radius: 3px; background: var(--bg-sunken); overflow: hidden; }
.sf-prog-b > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .2s; }
.sf-prog-t { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
#sf-prop-t:not(:empty) { margin-top: 8px; }
.sf-tp tr.best td { background: var(--ok-bg); }
.sf-tp tr.best td:first-child { box-shadow: inset 3px 0 0 var(--att); }
.sf-tp tr.cur td { font-weight: 700; }
.sf-tp tr.non td { color: var(--ink-4); }

/* l'export : UN bouton */
.sf-export { margin: 12px 10px 12px; padding-top: 10px; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.sf-exp-b { width: 100%; justify-content: center; height: 38px; }
.sf-exp-b svg.i { width: 15px; height: 15px; }

/* choisir une note d'un autre module (« Reprendre ») */
.sf-notes { position: fixed; z-index: 90; width: min(340px, calc(100vw - 16px)); max-height: min(420px, calc(100vh - 16px)); display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--r); box-shadow: var(--shadow-pop); overflow: hidden; }
.sf-notes-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 8px 9px 12px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.sf-notes-l { overflow: auto; padding: 4px; display: grid; gap: 1px; }
.sf-notes-l button { display: grid; gap: 1px; padding: 7px 9px; border-radius: 7px; font: inherit; text-align: left; }
.sf-notes-l button b { font-size: 12.5px; color: var(--ink); }
.sf-notes-l button span { font-size: 11px; color: var(--ink-3); }
.sf-notes-l button span:empty { display: none; }
.sf-notes-l button:hover, .sf-notes-l button:focus-visible { background: var(--accent-soft); }
.sf-notes-v { margin: 0; padding: 14px 12px; font-size: 12.5px; color: var(--ink-3); }

/* ------------------------------------------------------------------ tablette et téléphone : des cibles assez grandes */
@media (max-width: 1199px) {
  /* (au doigt, 44 px : la règle de l'établi — chaque bouton, chaque champ d'une ligne à bouton) */
  .sf-x { width: 44px; height: 44px; }
  .sf-som { grid-template-columns: 18px minmax(0, 1fr) minmax(0, 1fr) 44px; }
  .sf-k { grid-template-columns: minmax(0, 1fr) auto 44px; }
  .sf-jeu { grid-template-columns: 18px minmax(0, 1fr) 44px; }
  .sf-som > .field, .sf-k > .field, .sf-p > .field, .sf-jeu > .field.text { height: 44px; }
  .sf-chassis-b, .sf-grue-b { height: 44px; }
  .sf-vue .seg button, .sf-vue .field.select { height: 44px; }
  .sf-scia { width: 44px; height: 44px; }
  .sf-scia input { width: 20px; height: 20px; }
  .sf-lien { min-width: 44px; min-height: 44px; padding: 0 8px; margin: 0 -8px; }
  .sf-cas { min-height: 44px; padding: 9px 6px; font-size: 12.5px; }
  .sf-detail { min-height: 44px; }
  .sf-pied .et-add { min-width: 44px; }
  .sf-pos > summary { min-height: 44px; align-items: center; }
  /* (une ligne de contrôle ouvre son détail : au doigt, 44 px même quand elle tient sur une ligne) */
  #resultat .et-bloc .el.vc { min-height: 44px; justify-content: center; }
  .sf-exp-b { height: 46px; }
  .sf-prop-h .btn { height: 44px; }
  .sf-notes-l button { min-height: 44px; padding: 11px 10px; }
}
@media (max-width: 700px) {
  .sf-vue { margin-left: 0; width: 100%; }
  .sf-vue .field.select { max-width: none; flex: 1 1 140px; }
}
