/* Only the search target editor; the surrounding search layout is unchanged.
   Stesso linguaggio della finestra «Opzioni avanzate» (current-search.css):
   controlli alti 44px, raggio 9px, bordo #d7e0e7, freccia dei menu in fondo a
   destra, caselle allineate alla prima riga del testo. */
/* The target step must grow with the editor instead of clipping it at 100vh. */
html body #view-analysis #analysis-step-goal.is-active { height: auto; min-height: 0; max-height: none; overflow: visible; }
html #view-analysis #analysis-step-goal #client-target-editor { padding: 0; margin: 20px 0; overflow: hidden; background: #fff; border: 1px solid #dce4e0; border-radius: 16px; transition: border-color 140ms ease, box-shadow 140ms ease; }
html #view-analysis #analysis-step-goal #client-target-editor:has(> .client-target-card:hover) { border-color: #bfd8c9; box-shadow: 0 1px 2px #0b1f3a0a, 0 6px 16px #3d9a6314; }
html #view-analysis #analysis-step-goal #client-target-editor.needs-attention { background: #fffaf0; border-color: #ecd29b; }
html #view-analysis #analysis-step-goal #client-target-editor.needs-attention #client-target-summary { color: #79500b; }

/* --- Il riquadro: un pulsante che apre la finestra -------------------------- */
html #view-analysis #analysis-step-goal #client-target-editor > .client-target-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; min-height: 0; margin: 0; padding: 18px 22px; color: inherit; background: none; border: 0; border-radius: 0; box-shadow: none; font: inherit; text-align: left; cursor: pointer; }
html #view-analysis #analysis-step-goal #client-target-editor > .client-target-card:focus-visible { outline: 2px solid #488868; outline-offset: -2px; border-radius: 16px; }
html #view-analysis #analysis-step-goal #client-target-editor .client-editor-heading { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
html #view-analysis #analysis-step-goal #client-target-editor .client-editor-heading strong { color: #0b1f3a; font-size: 15px; font-weight: 600; line-height: 1.4; }
html #view-analysis #analysis-step-goal #client-target-editor #client-target-summary { overflow: hidden; color: #69798d; font-size: 12.5px; font-weight: 400; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }
html #view-analysis #analysis-step-goal #client-target-editor .client-editor-toggle { display: inline-flex; align-items: center; gap: 7px; flex: none; height: 34px; padding: 0 12px; color: #397757; background: #edf6f0; border-radius: 9px; font-size: 13px; font-weight: 600; transition: background-color 140ms ease; }
html #view-analysis #analysis-step-goal #client-target-editor > .client-target-card:hover .client-editor-toggle { background: #e2f0e7; }
html #view-analysis #analysis-step-goal #client-target-editor .client-editor-toggle .ui-icon { width: 15px; height: 15px; }

/* --- La finestra: misure, testata e piede delle opzioni avanzate ------------
   (current-search.css). Resta nel DOM dentro #client-target-editor, cosi'
   le regole dei campi qui sotto e l'ascolto degli input in clienti.js
   valgono come prima. */
html body #view-analysis #client-target-dialog { width: min(820px, calc(100vw - 40px)); max-width: none; height: fit-content; max-height: calc(100dvh - 40px); margin: auto; padding: 0; overflow: hidden; color: #0b1f3a; color-scheme: light; background: #fff; border: 1px solid #e0e6ec; border-radius: 20px; box-shadow: 0 24px 80px #14264026; }
html body #view-analysis #client-target-dialog[open] { animation: dialog-in 180ms ease-out; }
html body #view-analysis #client-target-dialog::backdrop { background: #10213a40; backdrop-filter: blur(4px); }
html #view-analysis #analysis-step-goal #client-target-editor .client-target-shell { display: flex; flex-direction: column; width: 100%; max-height: calc(100dvh - 42px); overflow: hidden; background: #fff; }
html #view-analysis #analysis-step-goal #client-target-editor .client-target-header { display: flex; flex: none; align-items: flex-start; justify-content: space-between; gap: 20px; margin: 0; padding: 22px 24px 18px; background: #fff; border-bottom: 1px solid #e9edf2; }
html #view-analysis #analysis-step-goal #client-target-editor .client-target-header .section-code { margin: 0 0 7px; color: #488868; font: 600 11px/1.4 var(--font-sans); letter-spacing: .1em; }
html #view-analysis #analysis-step-goal #client-target-editor #client-target-dialog-title { margin: 0; color: #0b1f3a; font: 500 26px/1.2 var(--font-display); letter-spacing: -.025em; }
html #view-analysis #analysis-step-goal #client-target-editor #client-target-dialog-copy { max-width: 560px; margin: 8px 0 0; color: #687c91; font: 400 13px/1.55 var(--font-sans); }
html #view-analysis #analysis-step-goal #client-target-editor .client-target-close { display: grid; place-items: center; flex: none; width: 40px; min-width: 40px; height: 40px; min-height: 40px; margin: 0; padding: 10px; color: #5b6d82; background: #f5f7f9; border: 1px solid #e3e8ed; border-radius: 11px; cursor: pointer; }
html #view-analysis #analysis-step-goal #client-target-editor .client-target-close:hover { color: #0b1f3a; background: #eef2f5; }
html #view-analysis #analysis-step-goal #client-target-editor .client-target-close .ui-icon { width: 18px; height: 18px; }

/* --- Sezioni ---------------------------------------------------------------- */
html #view-analysis #analysis-step-goal #client-target-editor .client-editor-body { flex: 1 1 auto; min-height: 0; padding: 0 24px; overflow-y: auto; overscroll-behavior: contain; }
html #view-analysis #analysis-step-goal #client-target-editor .client-editor-section:first-child { border-top: 0; }
html #view-analysis #analysis-step-goal #client-target-editor .client-editor-section { display: flex; flex-direction: column; padding: 22px 0 24px; border-top: 1px solid #e9eeeb; }
html #view-analysis #analysis-step-goal #client-target-editor .client-section-heading { display: flex; align-items: flex-start; gap: 12px; margin: 0 0 18px; }
html #view-analysis #analysis-step-goal #client-target-editor .client-step-number { display: grid; place-items: center; flex: none; width: 28px; height: 28px; margin-top: 1px; color: #397757; background: #edf6f0; border-radius: 8px; font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
html #view-analysis #analysis-step-goal #client-target-editor h3 { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 0; color: #0b1f3a; font-size: 15px; font-weight: 600; line-height: 1.5; }
html #view-analysis #analysis-step-goal #client-target-editor .client-section-heading p { margin: 3px 0 0; color: #69798d; font-size: 13px; line-height: 1.55; }
html #view-analysis #analysis-step-goal #client-target-editor .client-optional { padding: 2px 8px; color: #6d7d76; background: #eef2f0; border-radius: 999px; font-size: 11px; font-weight: 500; line-height: 1.5; letter-spacing: .02em; }
html #view-analysis #analysis-step-goal #client-target-editor #client-criteria-count:not(:empty) { padding: 2px 8px; color: #397757; background: #edf6f0; border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 1.5; }

/* --- Campi ------------------------------------------------------------------ */
html #view-analysis #analysis-step-goal #client-target-editor label { display: flex; flex-direction: column; gap: 7px; margin: 0; color: #29435d; font-size: 13px; font-weight: 500; line-height: 1.4; }
html #view-analysis #analysis-step-goal #client-target-editor :is(input:not([type="checkbox"]), select, textarea) { box-sizing: border-box; width: 100%; min-width: 0; height: 44px; min-height: 44px; margin: 0; padding: 0 14px; color: #0b1f3a; background: #fff; border: 1px solid #d7e0e7; border-radius: 9px; font: 400 14px/1.5 var(--font-sans); box-shadow: none; transition: border-color 140ms ease, box-shadow 140ms ease; }
html #view-analysis #analysis-step-goal #client-target-editor :is(input:not([type="checkbox"]), select, textarea):hover:not(:disabled) { border-color: #b9c6d0; }
html #view-analysis #analysis-step-goal #client-target-editor :is(input:not([type="checkbox"]), select, textarea):focus { border-color: #488868; outline: 0; box-shadow: 0 0 0 3px #4888681f; }
html #view-analysis #analysis-step-goal #client-target-editor :is(input, textarea)::placeholder { color: #8d99a9; opacity: 1; }
html #view-analysis #analysis-step-goal #client-target-editor textarea { height: auto; min-height: 76px; padding: 11px 14px; line-height: 1.55; resize: vertical; }
/* Il menu «Quanto conta?» resta nativo: la freccia e' la stessa dei menu
   della finestra delle opzioni, in fondo a destra. */
html #view-analysis #analysis-step-goal #client-target-editor select { padding-right: 40px; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='m5 7.5 5 5 5-5' stroke='%235A6579' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px 16px; cursor: pointer; }
/* Le due ricerche hanno la lente dentro il campo. */
html #view-analysis #analysis-step-goal #client-target-editor input[type="search"] { padding-left: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%237A8999' stroke-width='1.6' stroke-linecap='round'%3E%3Ccircle cx='9' cy='9' r='5.5'/%3E%3Cpath d='m13.2 13.2 3.3 3.3'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 13px center; background-size: 17px 17px; }
html #view-analysis #analysis-step-goal #client-target-editor small { margin: 0; color: #718093; font-size: 12px; font-weight: 400; line-height: 1.5; }
html #view-analysis #analysis-step-goal #client-target-editor .client-editor-section > small { margin-top: 8px; }
html #view-analysis #analysis-step-goal #client-target-editor label[for="client-target-label"] { margin-bottom: 20px; }

/* Numero e unita' sono un controllo solo, come raggio e celle nelle opzioni. */
html #view-analysis #analysis-step-goal #client-target-editor label[for="client-attractor-radius"] { max-width: 240px; margin-top: 18px; }
html #view-analysis #analysis-step-goal #client-target-editor .client-unit-input { display: grid; grid-template-columns: minmax(0, 1fr) auto; height: 44px; }
html #view-analysis #analysis-step-goal #client-target-editor .client-unit-input input { border-radius: 9px 0 0 9px; appearance: textfield; -moz-appearance: textfield; }
html #view-analysis #analysis-step-goal #client-target-editor .client-unit-input input::-webkit-inner-spin-button,
html #view-analysis #analysis-step-goal #client-target-editor .client-unit-input input::-webkit-outer-spin-button { margin: 0; -webkit-appearance: none; }
html #view-analysis #analysis-step-goal #client-target-editor .client-unit-input > span { display: grid; place-items: center; min-width: 48px; padding: 0 12px; color: #5b6d82; background: #f5f7f9; border: 1px solid #d7e0e7; border-left: 0; border-radius: 0 9px 9px 0; font-size: 13px; font-weight: 500; }

/* Caselle: allineate alla prima riga del testo, anche quando va a capo. */
html #view-analysis #analysis-step-goal #client-target-editor input[type="checkbox"] { flex: none; width: 17px; height: 17px; margin: 1.5px 0 0; accent-color: #488868; cursor: pointer; }

/* --- Elenco di categorie e poli ------------------------------------------- */
html #view-analysis #analysis-step-goal #client-target-editor .client-category-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 8px; }
html #view-analysis #analysis-step-goal #client-target-editor :is(#client-category-count, #client-attractor-count) { padding: 2px 8px; color: #5b6d82; background: #f1f4f6; border-radius: 999px; font-size: 11.5px; font-weight: 500; line-height: 1.5; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* L'elenco scorre dentro un riquadro suo: senza bordo non si capiva che
   sotto le prime righe ce n'erano altre 380. */
html #view-analysis #analysis-step-goal #client-target-editor :is(#client-category-options, #client-attractor-options) { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-height: 300px; margin: 10px 0 0; padding: 0 12px 12px; overflow-y: auto; overscroll-behavior: contain; background: #fafbfc; border: 1px solid #e1e7ec; border-radius: 10px; }
html #view-analysis #analysis-step-goal #client-target-editor :is(#client-category-options, #client-attractor-options):empty { display: none; }
/* Le categorie ora sono ~390 raggruppate per settore: il gruppo occupa
   tutta la riga e tiene la sua griglia interna. Il nome del gruppo resta in
   vista mentre si scorre. */
html #view-analysis #analysis-step-goal #client-target-editor .client-category-group { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
html #view-analysis #analysis-step-goal #client-target-editor .client-category-group > h4 { position: sticky; top: 0; z-index: 1; grid-column: 1 / -1; margin: 0 -12px; padding: 12px 12px 4px; color: #6d7d76; background: #fafbfc; font-size: 11px; font-weight: 600; line-height: 1.4; letter-spacing: .05em; text-transform: uppercase; }
html #view-analysis #analysis-step-goal #client-target-editor .client-category-option { flex-direction: row; align-items: flex-start; gap: 9px; min-height: 42px; padding: 10px 11px; color: #233c56; background: #fff; border: 1px solid #e1e7ec; border-radius: 9px; cursor: pointer; font-size: 13px; font-weight: 400; line-height: 20px; transition: border-color 140ms ease, background-color 140ms ease; }
html #view-analysis #analysis-step-goal #client-target-editor .client-category-option > span { min-width: 0; overflow-wrap: anywhere; }
html #view-analysis #analysis-step-goal #client-target-editor .client-category-option:hover:not(:has(:disabled)) { border-color: #b9c9c0; }
html #view-analysis #analysis-step-goal #client-target-editor .client-category-option:has(:checked) { color: #2b6b49; background: #edf7f0; border-color: #8bbb9b; font-weight: 500; }
html #view-analysis #analysis-step-goal #client-target-editor .client-category-option:has(:focus-visible) { outline: 2px solid #488868; outline-offset: 2px; }
html #view-analysis #analysis-step-goal #client-target-editor .client-category-option:has(:disabled) { opacity: .5; cursor: not-allowed; }
html #view-analysis #analysis-step-goal #client-target-editor :is(#client-category-empty, #client-attractor-empty) { margin: 10px 0 0; padding: 14px; color: #69798d; background: #fafbfc; border: 1px dashed #d7e0e7; border-radius: 10px; font-size: 13px; line-height: 1.5; text-align: center; }
html #view-analysis #analysis-step-goal #client-target-editor [hidden] { display: none !important; }

/* --- Caratteristiche ------------------------------------------------------- */
html #view-analysis #analysis-step-goal #client-target-editor .client-mode-note:not(:empty) { margin: 0 0 16px; padding: 12px 14px; color: #50697f; background: #f3f6f8; border-radius: 10px; font-size: 13px; line-height: 1.6; }
html #view-analysis #analysis-step-goal #client-target-editor .client-mode-note:empty { display: none; }
html #view-analysis #analysis-step-goal #client-target-editor #client-criteria { display: flex; flex-direction: column; gap: 12px; }
html #view-analysis #analysis-step-goal #client-target-editor .client-criterion { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; gap: 16px; margin: 0; padding: 0 16px 16px; background: #fff; border: 1px solid #e1e7ec; border-radius: 12px; }
html #view-analysis #analysis-step-goal #client-target-editor .client-criterion-heading { display: flex; align-items: center; justify-content: space-between; grid-column: 1 / -1; gap: 12px; margin: 0 -16px; padding: 8px 8px 8px 16px; background: #fafbfc; border-bottom: 1px solid #e9eef1; border-radius: 12px 12px 0 0; }
html #view-analysis #analysis-step-goal #client-target-editor .client-criterion-heading strong { color: #397757; font-size: 12px; font-weight: 600; letter-spacing: .02em; }
html #view-analysis #analysis-step-goal #client-target-editor .client-question,
html #view-analysis #analysis-step-goal #client-target-editor .client-criterion-extra { grid-column: 1 / -1; }
html #view-analysis #analysis-step-goal #client-target-editor .client-criterion-extra { margin: 0 -16px -16px; padding: 0 16px; border-top: 1px solid #e9eef1; }
html #view-analysis #analysis-step-goal #client-target-editor .client-criterion-extra > summary { display: flex; align-items: center; gap: 8px; min-height: 44px; color: #35546a; font-size: 12.5px; font-weight: 500; list-style: none; cursor: pointer; }
html #view-analysis #analysis-step-goal #client-target-editor .client-criterion-extra > summary::-webkit-details-marker { display: none; }
html #view-analysis #analysis-step-goal #client-target-editor .client-criterion-extra > summary::before { content: ""; flex: none; width: 6px; height: 6px; margin: 0 4px 0 2px; border-right: 1.6px solid #5a6579; border-bottom: 1.6px solid #5a6579; transform: rotate(-45deg); transition: transform 140ms ease; }
html #view-analysis #analysis-step-goal #client-target-editor .client-criterion-extra[open] > summary::before { transform: rotate(45deg); }
html #view-analysis #analysis-step-goal #client-target-editor .client-criterion-extra > summary span { color: #85928e; font-size: 11.5px; font-weight: 400; }
html #view-analysis #analysis-step-goal #client-target-editor .client-criterion-extra[open] { padding-bottom: 16px; }
html #view-analysis #analysis-step-goal #client-target-editor .client-criterion-extra label { margin-top: 4px; }
html #view-analysis #analysis-step-goal #client-target-editor .client-criterion-extra label + label { margin-top: 14px; }
html #view-analysis #analysis-step-goal #client-target-editor .client-check-label { flex-direction: row; align-items: flex-start; gap: 10px; color: #233c56; font-weight: 400; line-height: 20px; cursor: pointer; }
html #view-analysis #analysis-step-goal #client-target-editor .client-criteria-empty { margin: 0; padding: 18px; color: #69798d; background: #fafbfc; border: 1px dashed #d7e0e7; border-radius: 12px; font-size: 13px; line-height: 1.6; text-align: center; }

/* --- Pulsanti --------------------------------------------------------------- */
html #view-analysis #analysis-step-goal #client-target-editor .button { display: inline-flex; height: auto; align-items: center; justify-content: center; gap: 6px; width: auto; min-height: 42px; margin: 0; padding: 10px 16px; color: #35546a; background: white; border: 1px solid #d7e0e7; border-radius: 10px; font-size: 13px; font-weight: 500; box-shadow: none; }
html #view-analysis #analysis-step-goal #client-target-editor .button:hover:not(:disabled) { background: #f6f8fa; border-color: #c4d0da; }
/* «Aggiungi» chiude la lista: largo quanto le schede, tratteggiato come un posto vuoto. */
html #view-analysis #analysis-step-goal #client-target-editor #client-add-criterion { width: 100%; min-height: 46px; margin-top: 12px; color: #397757; background: #fff; border: 1px dashed #a9cbb6; font-weight: 600; }
html #view-analysis #analysis-step-goal #client-target-editor #client-add-criterion:hover:not(:disabled) { background: #f3faf5; border-color: #488868; }
html #view-analysis #analysis-step-goal #client-target-editor [data-client-remove] { min-height: 32px; padding: 4px 10px; color: #93615c; background: transparent; border-color: transparent; font-size: 12px; }
html #view-analysis #analysis-step-goal #client-target-editor [data-client-remove]:hover { background: #fcf0ee; border-color: transparent; }
html #view-analysis #analysis-step-goal #client-target-editor #client-save-target { color: white; background: #488868; border-color: #488868; font-weight: 600; }
html #view-analysis #analysis-step-goal #client-target-editor #client-save-target:hover:not(:disabled) { background: #397557; border-color: #397557; }
html #view-analysis #analysis-step-goal #client-target-editor .button:disabled { opacity: .5; cursor: not-allowed; }

/* --- Piede: fuori dal corpo che scorre, «Salva» sempre in vista. -------------- */
html #view-analysis #analysis-step-goal #client-target-editor .client-editor-footer { display: flex; flex: none; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 14px; margin: 0; padding: 16px 24px; background: #fff; border-top: 1px solid #e9edf2; }
html #view-analysis #analysis-step-goal #client-target-editor #client-target-status { flex: 1; min-width: 200px; margin: 0; color: #617668; font-size: 12px; line-height: 1.5; }
html #view-analysis #analysis-step-goal #client-target-editor .action-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 0 auto; }
html #view-analysis #analysis-step-goal #client-target-editor :is(button, summary):focus-visible { outline: 2px solid #488868; outline-offset: 3px; }

@media (max-width: 650px) {
  html #view-analysis #analysis-step-goal #client-target-editor > .client-target-card { padding: 16px; }
  html body #view-analysis #client-target-dialog { width: calc(100vw - 24px); max-height: calc(100dvh - 24px); border-radius: 16px; }
  html #view-analysis #analysis-step-goal #client-target-editor .client-target-shell { max-height: calc(100dvh - 26px); }
  html #view-analysis #analysis-step-goal #client-target-editor .client-target-header { gap: 12px; padding: 18px 16px; }
  html #view-analysis #analysis-step-goal #client-target-editor #client-target-dialog-title { font-size: 23px; }
  html #view-analysis #analysis-step-goal #client-target-editor .client-editor-body { padding-inline: 16px; }
  html #view-analysis #analysis-step-goal #client-target-editor .client-editor-footer { padding: 12px 16px; }
  html #view-analysis #analysis-step-goal #client-target-editor :is(#client-category-options, .client-category-group) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html #view-analysis #analysis-step-goal #client-target-editor .client-criterion { grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 0 12px 12px; }
  html #view-analysis #analysis-step-goal #client-target-editor .client-criterion-heading { margin-inline: -12px; padding-left: 12px; }
  html #view-analysis #analysis-step-goal #client-target-editor .client-criterion-extra { margin: 0 -12px -12px; padding-inline: 12px; }
  html #view-analysis #analysis-step-goal #client-target-editor :is(input:not([type="checkbox"]), select, textarea) { font-size: 16px; }
  html #view-analysis #analysis-step-goal #client-target-editor .action-row { width: 100%; }
  html #view-analysis #analysis-step-goal #client-target-editor .action-row .button { flex: 1; }
  html #view-analysis #analysis-step-goal #client-target-editor .client-editor-toggle { padding: 0 9px; font-size: 0; gap: 0; }
  html #view-analysis #analysis-step-goal #client-target-editor label[for="client-attractor-radius"] { max-width: none; }
}
