/* Styles des écrans du lot 3, compte (/v2) : Profil et sécurité, Pause d’abonnement,
   Parrainage, Aide et diagnostic, Automatisations, Espace agence. Préfixe « cp- ».
   « Atelier calme » : les écrans s’appuient sur les primitives at- (components.css).
   Ici seulement ce qui leur est propre, à plat : pas de carte, pas de pastille teintée.
   Ces écrans ne s’affichent jamais dans l’éditeur (body.builder-active). */

.cp-screen { min-width: 0; }
.cp-screen [hidden], .cp-dialog [hidden] { display: none !important; }
.cp-screen p, .cp-dialog p { margin: 0; }
.cp-muted { color: var(--muted); }
.cp-small { font-size: var(--text-xs); }
.cp-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.cp-actions .button { white-space: nowrap; }
.cp-screen svg, .cp-dialog svg { flex: none; }
.cp-error-text { color: var(--red); font-weight: 500; }
.cp-screen .at-page-head h1 { outline: none; }

/* En-tête : état ou chiffre à droite, en texte. */
.cp-heading-side { gap: var(--space-3); }
.cp-level { display: grid; justify-items: end; gap: 2px; }
.cp-level-steps { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px 10px; color: var(--muted); font-size: var(--text-xs); }
.cp-level-steps .on { color: var(--ink-2); }
.cp-usage { color: var(--muted); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.cp-usage strong { color: var(--ink); font-weight: 600; }
.cp-brand-name { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: var(--text-sm); font-weight: 500; }
.cp-brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cp-brand, var(--blue)); }

/* Prochaine étape : une ligne entre deux filets. */
.cp-next .at-row { padding-block: 12px; }
.cp-next .at-row:hover { background: transparent; }
.cp-next .at-row-meta { max-width: 72ch; }

/* Lecture seule, erreurs en ligne. */
.cp-note { margin: 0; }
.cp-error svg { width: 14px; height: 14px; margin-top: 2px; }
.at-form-actions .cp-error { flex-basis: 100%; order: -1; }

/* Champs : libellé à gauche (primitives at-field). */
.cp-optional { display: inline; margin: 0; color: var(--muted); font-weight: 400; }
.cp-screen .at-field-label small { display: block; }
.cp-static { padding-top: 8px; color: var(--ink); overflow-wrap: anywhere; }
.cp-check { display: flex; align-items: flex-start; gap: 10px; font-size: var(--text-md); line-height: 1.45; cursor: pointer; }
.cp-check input { width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--blue); }
.cp-otp { max-width: 220px; font-size: 22px !important; letter-spacing: .32em; text-align: center; font-variant-numeric: tabular-nums; }
.cp-search { position: relative; width: min(340px, 100%); min-width: 0; }
.cp-search svg { position: absolute; left: 10px; top: 50%; width: 16px; height: 16px; color: var(--muted); transform: translateY(-50%); pointer-events: none; }
.cp-search input, .cp-copy-row input, .cp-knob input, .cp-add-action select {
  width: 100%; min-height: var(--control-md); padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--field-radius); color: var(--ink); background: var(--surface); font: inherit;
}
.cp-search input { padding-left: 32px; }
.cp-screen :is(.cp-search input, .cp-copy-row input):focus-visible, .cp-dialog .cp-add-action select:focus-visible { border-color: var(--blue); outline: 0; box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 20%, transparent); }

/* Vide et chargement. */
.cp-empty .at-link { margin-left: 0; }
.cp-loading { display: grid; gap: var(--space-4); }

/* Listes, puces simples, faits en deux colonnes. */
.cp-bullets, .cp-rules-text, .cp-what { display: grid; gap: 6px; max-width: 70ch; margin: 0; padding-left: 18px; line-height: 1.5; }
.cp-what { padding-top: 8px; color: var(--ink-2); }
.cp-facts { display: grid; margin: 0; border-top: 1px solid var(--line); }
.cp-facts div { display: grid; grid-template-columns: var(--field-label-width) minmax(0, 1fr); gap: 4px var(--space-6); padding: 12px 0; border-bottom: 1px solid var(--line); }
.cp-facts dt { color: var(--muted); font-size: var(--text-sm); }
.cp-facts dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.cp-current { margin-left: 6px; color: var(--green); font-size: var(--text-sm); font-weight: 500; }
.cp-subtitle { margin: 0; color: var(--muted); font-size: var(--text-sm); font-weight: 500; }

/* Tableau à filets ; lignes empilées sur téléphone. */
.cp-table-wrap { min-width: 0; }
.cp-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.cp-table :is(th, td) { padding: 10px var(--space-2); border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.cp-table thead th { color: var(--muted); font-size: var(--text-xs); font-weight: 500; border-top: 1px solid var(--line); }
.cp-table tbody th { font-weight: 400; }
.cp-table tbody th strong { display: block; color: var(--ink); font-weight: 500; }
.cp-table .is-num { text-align: right; font-variant-numeric: tabular-nums; }
.cp-table tbody tr:hover > * { background: var(--row-hover); }
.cp-table td > .at-status { display: flex; }

/* Profil et sécurité ----------------------------------------------------- */
.cp-sec-tabs { margin-top: calc(var(--space-2) * -1); }
.cp-panel { display: grid; gap: var(--space-6); min-width: 0; }
.cp-panel > .at-section ~ .at-section { padding-top: var(--space-6); border-top: 1px solid var(--line); }
.cp-rules { display: grid; gap: 2px; margin: 4px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: var(--text-xs); }
.cp-rules li { display: flex; align-items: center; gap: 6px; }
.cp-rules li svg { width: 13px; height: 13px; }
.cp-rules li.ok { color: var(--green); }
.cp-danger-title { color: var(--red); }
.cp-screen .button.cp-danger-text, .cp-dialog .button.cp-danger-text { border-color: var(--line-strong); color: var(--red); background: transparent; }
.cp-screen .button.cp-danger-text:hover { border-color: var(--red); color: var(--red-strong); }

/* Double validation (fenêtres) */
.cp-qr-step { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-5); align-items: center; }
.cp-qr { width: 180px; max-width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.cp-qr svg { display: block; width: 100%; height: auto; }
.cp-steps { display: grid; gap: 8px; margin: 0; padding-left: 20px; line-height: 1.5; }
.cp-details summary { display: flex; align-items: center; min-height: var(--touch-min); color: var(--blue-strong); font-weight: 500; cursor: pointer; }
.cp-details[open] { display: grid; gap: 8px; }
.cp-secret code { display: inline-block; max-width: 100%; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); font-family: var(--font-mono); font-size: 15px; letter-spacing: .06em; overflow-wrap: anywhere; user-select: all; }
.cp-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 20px; margin: 0; padding: 12px 12px 12px 34px; border-block: 1px solid var(--line); }
.cp-codes code { font-family: var(--font-mono); font-size: 15px; letter-spacing: .04em; font-variant-numeric: tabular-nums; }

/* Pause : durées en lignes à cocher. */
.cp-radios { display: grid; border-top: 1px solid var(--line); }
.cp-radio { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px var(--space-2); border: 0; border-bottom: 1px solid var(--line); color: var(--ink); background: transparent; font: inherit; text-align: left; cursor: pointer; transition: background-color var(--dur-2) var(--ease-soft); }
.cp-radio:hover:not(:disabled) { background: var(--row-hover); }
.cp-radio:disabled { color: var(--muted); cursor: not-allowed; }
.cp-radio:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.cp-radio-mark { flex: none; width: 16px; height: 16px; border: 1.5px solid var(--line-hover); border-radius: 50%; }
.cp-radio[aria-pressed="true"] .cp-radio-mark { border: 5px solid var(--ink); }
.cp-radio-text { display: grid; gap: 1px; }
.cp-radio-text strong { font-weight: 500; }
.cp-radio-text small { color: var(--muted); font-size: var(--text-sm); }

/* Parrainage */
.cp-stats { padding-bottom: var(--space-2); }
.cp-referral { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: var(--space-8); align-items: start; }
.cp-copy-row { display: flex; gap: var(--space-2); min-width: 0; }
.cp-copy-row input { flex: 1; min-width: 0; background: var(--surface-2); font-family: var(--font-mono); font-size: var(--text-sm); }
.cp-qr-card { display: grid; justify-items: start; gap: var(--space-2); margin: 0; }
.cp-qr-card .cp-qr { width: 160px; }

/* Aide et diagnostic */
.cp-help-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--space-9); align-items: start; }
.cp-help-grid > .at-section ~ .at-section { padding-top: 0; border-top: 0; }
.cp-checks .at-row { align-items: flex-start; }
.cp-checks .at-status { white-space: normal; }
.cp-check-summary { color: var(--ink-2); max-width: 70ch; }
.cp-check-tech { margin-top: 4px; border-top: 0; }
.cp-check-tech > summary { min-height: 32px; font-size: var(--text-sm); font-weight: 500; }
.cp-article { padding: 0; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
.cp-article:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 2px; }
.cp-articles .at-row-main { position: static; }
.cp-articles-empty { list-style: none; }
.cp-article-body { display: grid; gap: 10px; line-height: 1.6; }

/* Automatisations */
.cp-template .cp-sentence { display: block; max-width: 70ch; color: var(--ink); line-height: 1.6; }
.cp-knob { display: inline-block; vertical-align: baseline; }
.cp-knob input { display: inline-block; width: 60px; min-height: 32px; padding: 0 6px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.cp-switch-lead { width: auto; }
.cp-rules-list .at-row { align-items: flex-start; }
.cp-rules-list .is-off :is(.at-row-title, .cp-rule-sentence) { color: var(--muted); }
.cp-rule-sentence { color: var(--ink-2); font-size: var(--text-sm); line-height: 1.5; }
.cp-runs > li { border-bottom: 1px solid var(--line); }
.cp-runs summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: var(--touch-min); padding: 8px var(--space-2); cursor: pointer; list-style: none; }
.cp-runs summary::-webkit-details-marker { display: none; }
.cp-runs summary:hover { background: var(--row-hover); }
.cp-runs summary strong { font-weight: 500; }
.cp-runs summary .cp-muted { margin-left: auto; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.cp-runs .cp-steps-list { padding: 4px var(--space-2) 12px 28px; }
.cp-steps-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; font-size: var(--text-sm); line-height: 1.45; }
.cp-steps-list li { display: flex; align-items: flex-start; gap: 8px; }
.cp-steps-list li svg { width: 16px; height: 16px; margin-top: 1px; color: var(--muted); }
.cp-steps-list .is-success svg { color: var(--green); }
.cp-steps-list .is-error svg { color: var(--red); }
.cp-fieldset { display: grid; gap: 10px; min-width: 0; margin: 0; padding: 0; border: 0; }
.cp-fieldset legend { padding: 0 0 6px; font-size: var(--text-sm); font-weight: 500; }
.cp-action-list { display: grid; margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); counter-reset: cp-action; }
.cp-action-list > li { display: grid; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); counter-increment: cp-action; }
.cp-action-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cp-action-head strong { font-weight: 500; }
.cp-action-head strong::before { content: counter(cp-action) ". "; color: var(--muted); font-variant-numeric: tabular-nums; }
.cp-add-action { display: flex; flex-wrap: wrap; gap: 8px; }
.cp-add-action select { flex: 1 1 220px; width: auto; }

/* Espace agence */
.cp-filters { margin-top: calc(var(--space-1) * -1); }
.cp-clients tr.is-current > th { box-shadow: inset var(--accent-bar) 0 0 var(--blue); }
.cp-clients th, .cp-clients td { padding-block: 12px; }
.cp-clients td > * + * { margin-top: 4px; }
.cp-clients .cp-muted.cp-small, .cp-clients th > .cp-muted { display: block; }
.cp-client-sites { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.cp-client-alert { display: block; color: var(--ink-2); font-size: var(--text-xs); max-width: 36ch; }
.cp-cell-action { text-align: right; white-space: nowrap; }
.cp-approvals .at-row { align-items: flex-start; }
.cp-approvals .at-row-title .at-status { margin-left: 8px; }
.cp-comments { display: grid; gap: 6px; margin: 6px 0 0; padding: 0 0 0 12px; border-left: 2px solid var(--line-strong); list-style: none; font-size: var(--text-sm); }
.cp-comments p { margin-top: 2px; white-space: pre-wrap; }
.cp-color { display: flex; align-items: center; gap: 10px; }
.cp-color input[type="color"] { width: 52px; min-height: var(--control-md); padding: 3px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.cp-color code { font-family: var(--font-mono); font-size: var(--text-sm); }

/* Console d’administration (appelée par app.js) */
.admin-support-panel { margin-top: 18px; }
.cp-admin-tickets { display: grid; margin: 0; padding: 0; list-style: none; }
.cp-admin-tickets > li { display: grid; gap: 6px; padding: 12px 0; border-top: 1px solid var(--line); }
.cp-admin-tickets > li:first-child { border-top: 0; }
.cp-admin-tickets .button { justify-self: start; }
.cp-admin-message { white-space: pre-wrap; font-size: var(--text-sm); }
.cp-approval-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; }

/* Fenêtres : champs empilés, sans filet entre eux. */
.cp-dialog { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: var(--radius-xl); color: var(--ink); background: var(--surface); box-shadow: var(--shadow-lg); }
.cp-dialog.cp-dialog-wide { width: min(720px, calc(100vw - 24px)); }
.cp-dialog.cp-dialog-small { width: min(440px, calc(100vw - 24px)); }
.cp-dialog-form { display: flex; flex-direction: column; max-height: calc(100dvh - 24px); }
.cp-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.cp-dialog-head h2 { margin: 0; font-size: var(--text-lg); font-weight: var(--weight-heading); }
.cp-dialog-head p { margin: 4px 0 0; color: var(--muted); font-size: var(--text-sm); line-height: 1.5; }
.cp-dialog-body { display: grid; gap: var(--space-4); padding: 16px 20px; overflow-y: auto; }
.cp-dialog-body p { line-height: 1.5; }
.cp-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; border-top: 1px solid var(--line); }
.cp-dialog .at-field, .cp-screen .at-form.is-stacked .at-field { grid-template-columns: minmax(0, 1fr); padding: 0; border-bottom: 0; }
.cp-dialog .at-field-label, .cp-screen .at-form.is-stacked .at-field-label { padding-top: 0; }
.cp-dialog .at-field-control { max-width: none; }

/* Téléphone : une colonne, cibles de 44 px, aucun défilement horizontal. */
@media (max-width: 1100px) {
  .cp-help-grid { grid-template-columns: minmax(0, 1fr); gap: var(--space-6); }
  .cp-help-grid > .at-section ~ .at-section { padding-top: var(--space-6); border-top: 1px solid var(--line); }
}
@media (max-width: 720px) {
  .cp-level { justify-items: start; }
  .cp-level-steps { justify-content: flex-start; }
  .cp-facts div { grid-template-columns: minmax(0, 1fr); }
  .cp-referral { grid-template-columns: minmax(0, 1fr); gap: var(--space-5); }
  .cp-qr-step { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .cp-codes { grid-template-columns: minmax(0, 1fr); }
  .cp-copy-row { flex-direction: column; }
  .cp-search { width: 100%; }
  .cp-table thead { display: none; }
  .cp-table, .cp-table tbody, .cp-table tr, .cp-table th, .cp-table td { display: block; width: 100%; }
  .cp-table tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .cp-table :is(th, td) { padding: 3px 0; border: 0; text-align: left; }
  .cp-table td[data-label]::before { display: block; color: var(--muted); font-size: var(--text-xs); content: attr(data-label); }
  .cp-table .is-num, .cp-cell-action { text-align: left; }
  .cp-table tbody tr:hover > * { background: transparent; }
  .cp-clients tr.is-current > th { box-shadow: none; }
  .cp-screen :is(.button, .at-link, .cp-article, select, input:not([type="checkbox"], [type="radio"], [type="color"])), .cp-dialog :is(.button, select, input:not([type="checkbox"], [type="radio"])) { min-height: var(--touch-min); }
  .cp-screen .at-row-actions .icon-button { width: var(--touch-min); height: var(--touch-min); }
  .cp-dialog-actions .button { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) {
  .cp-screen *, .cp-dialog * { transition: none !important; }
}

/* Largeurs étroites : la grille de l’écran ne s’élargit jamais au-delà de la zone principale. */
.cp-screen.at-page { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 860px) {
  .cp-screen .at-page-head { flex-wrap: nowrap; }
  .cp-screen .at-page-head > :not(:first-child) { min-width: 0; max-width: 100%; }
}

/* Parrainage : la colonne du QR code est plus haute que le formulaire, pas de filet orphelin. */
.cp-referral .at-form > .at-field:last-child { border-bottom: 0; }
/* Aide : grand écran, les articles en deux colonnes de lignes. */
@media (min-width: 1200px) {
  .cp-articles { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--space-9); }
  .cp-articles > .cp-articles-empty { grid-column: 1 / -1; }
}
/* Sections repliées : sur téléphone, la précision passe sous le titre au lieu d’être écrasée à droite. */
@media (max-width: 720px) {
  .cp-screen details.ui-advanced > summary { flex-wrap: wrap; row-gap: 2px; }
  .cp-screen details.ui-advanced > summary > span { flex: 1 1 0; min-width: 0; }
  .cp-screen details.ui-advanced > summary > small { order: 3; flex: 1 1 100%; margin: 0; text-align: left; }
}
/* Section repliée posée sous une autre section : le filet de la section suffit. */
.cp-screen .at-section + .at-section > details.ui-advanced:first-child { border-top: 0; }
.cp-screen .at-section + .at-section:has(> details.ui-advanced:first-child) { padding-top: var(--space-2); }
