/* Responsive : page pcm (fenêtre étroite → large). Tout est scopé body.embed. */
body.embed #page-pcm{container:pcm / inline-size;min-width:0}
body.embed #page-pcm .pg-title{font-size:clamp(18px,1.6vw + 10px,24px);overflow-wrap:anywhere}
body.embed #page-pcm .pg-sub{max-width:80ch;overflow-wrap:anywhere}
body.embed #page-pcm .toolbar-card{padding:clamp(8px,1.2cqi,14px) clamp(10px,2cqi,16px)}
body.embed #page-pcm .filters-row{gap:8px 10px}
body.embed #page-pcm #pcm-search{flex:1 1 240px;min-width:0}
body.embed #page-pcm #pcm-defined-filter{flex:0 1 220px;min-width:0;max-width:100%;min-height:38px}
body.embed #page-pcm #pcm-search{min-height:38px}

/* Barre de sélection : collante en bas, sans masquer le contenu (marge sous le tableau) */
body.embed #page-pcm .selection-bar{position:sticky;bottom:8px;top:auto;z-index:6;display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px 12px;box-shadow:0 6px 24px rgba(0,0,0,.18)}
body.embed #page-pcm .selection-bar[hidden]{display:none}
body.embed #page-pcm .selection-bar>div{display:flex;flex-wrap:wrap;gap:8px}
body.embed #page-pcm .selection-bar .btn{min-height:36px}

/* Tableau */
body.embed #page-pcm .table-card{max-height:max(320px,calc(100vh - 250px));overflow:auto;overscroll-behavior:contain}
body.embed #page-pcm #pcm-table{table-layout:auto;min-width:0}
body.embed #page-pcm #pcm-table td.pcm-name{overflow-wrap:anywhere;min-width:180px}
body.embed #page-pcm #pcm-table .pcm-num{width:clamp(96px,13cqi,150px)}
body.embed #page-pcm .pcm-cell-input,body.embed #page-pcm .pcm-all-input{width:100%;max-width:120px;min-height:36px;padding:6px 8px}
body.embed #page-pcm .pcm-toggle-links{min-height:36px;white-space:nowrap}
body.embed #page-pcm .pcm-links-row ul{overflow-wrap:anywhere}
body.embed #page-pcm .pcm-links-row td{padding-left:clamp(12px,3cqi,28px)}
body.embed #page-pcm #pcm-table tr:has(.pcm-cell-input:focus-visible) td{background:var(--accent-soft)}

@container pcm (max-width:900px){
  body.embed #page-pcm #pcm-table th,body.embed #page-pcm #pcm-table td{padding:9px 10px}
  body.embed #page-pcm #pcm-table th.pcm-num{font-size:11px;letter-spacing:.02em}
}

/* Cartes empilées : une prestation = une carte, les 3 temps en colonnes */
@container pcm (max-width:720px){
  body.embed #page-pcm .table-card{max-height:none;overflow:visible;background:transparent;border:0;box-shadow:none}
  body.embed #page-pcm #pcm-table,body.embed #page-pcm #pcm-table tbody{display:block;width:100%}
  body.embed #page-pcm #pcm-table thead{display:none}
  body.embed #page-pcm #pcm-table tr{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px 10px;padding:12px;margin-bottom:10px;background:var(--card);border:1px solid var(--border);border-radius:var(--radius)}
  body.embed #page-pcm #pcm-table tr:hover td{background:transparent}
  body.embed #page-pcm #pcm-table td{display:block;padding:0;border:0;min-width:0;background:transparent}
  body.embed #page-pcm #pcm-table td.pcm-name{grid-column:1/-1;min-width:0}
  body.embed #page-pcm #pcm-table td.pcm-links{grid-column:1/-1}
  body.embed #page-pcm #pcm-table td.pcm-links:empty,body.embed #page-pcm #pcm-table tr.pcm-all-row>td:empty{display:none}
  body.embed #page-pcm #pcm-table td.pcm-num{width:auto;text-align:left}
  body.embed #page-pcm #pcm-table td.pcm-num::before{content:attr(data-label);display:block;margin-bottom:4px;font-size:11.5px;font-weight:600;color:var(--sub);line-height:1.25}
  body.embed #page-pcm .pcm-cell-input,body.embed #page-pcm .pcm-all-input{max-width:none;min-height:40px;text-align:center}
  body.embed #page-pcm #pcm-table tr.pcm-all-row{background:var(--accent-soft);border-color:var(--accent)}
  body.embed #page-pcm #pcm-table tr.pcm-all-row td{background:transparent!important;border:0!important}
  body.embed #page-pcm #pcm-table tr.pcm-links-row{display:block;margin-top:-6px;background:var(--chip)}
  body.embed #page-pcm #pcm-table tr.pcm-links-row td{padding:0}
  body.embed #page-pcm #pcm-table tr:has(.pcm-cell-input:focus-visible){border-color:var(--accent)}
  body.embed #page-pcm .pcm-empty{display:block}
  body.embed #page-pcm #pcm-table tr:has(.pcm-empty){display:block;padding:0}
}
@container pcm (max-width:440px){
  body.embed #page-pcm #pcm-table tr{grid-template-columns:1fr}
  body.embed #page-pcm #pcm-table td.pcm-num{display:grid;grid-template-columns:minmax(0,1fr) 110px;align-items:center;gap:8px}
  body.embed #page-pcm #pcm-table td.pcm-num::before{margin:0;font-size:12.5px}
}
@container pcm (max-width:560px){
  body.embed #page-pcm .filters-row>*{flex:1 1 100%!important;max-width:none!important}
  body.embed #page-pcm .selection-bar>div{width:100%}
  body.embed #page-pcm .selection-bar>div .btn{flex:1 1 auto}
}

/* Fenêtres basses */
@media (max-height:700px){
  body.embed #page-pcm .toolbar-card{padding-top:6px;padding-bottom:6px}
  body.embed #page-pcm .pg-sub{font-size:13px}
}

/* Modale : tient dans la fenêtre, défilement interne */
body.embed #pcm-edit-modal .modal{width:min(720px,94vw);max-height:calc(100vh - 32px);max-height:calc(100dvh - 32px);overflow:auto;display:flex;flex-direction:column;padding:clamp(14px,3vw,24px)}
body.embed #pcm-edit-modal .form-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px}
body.embed #pcm-edit-modal .form-grid .input{min-height:38px}
body.embed #pcm-edit-modal .modal-actions{position:sticky;bottom:calc(-1 * clamp(14px,3vw,24px));display:flex;flex-wrap:wrap;justify-content:flex-end;gap:8px;padding:12px 0 2px;margin-top:12px;background:var(--card);border-top:1px solid var(--border)}
body.embed #pcm-edit-modal .modal-actions .btn{min-height:38px}
@media (max-width:520px){
  body.embed #pcm-edit-modal .modal-actions .btn{flex:1 1 auto}
}
