/* Modale condivisa (rete pubblica, workspace, backoffice).

   `<dialog>` nativo: gestisce da sé fuoco, ESC e sfondo inerte. Rifarlo con dei
   div significa reimplementare male proprio quelle tre cose, che sono quelle
   che contano per chi naviga da tastiera. */
dialog.modal {
  width: min(620px, 94vw); max-height: 88vh; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 18px;
  background: var(--bg, var(--surface)); color: var(--text);
  padding: 2rem; box-shadow: 0 20px 60px rgba(0,0,0,.28);
}
dialog.modal::backdrop { background: rgba(16, 14, 34, .55); }
dialog.modal h2 { margin: 0 0 6px; font-size: 20px; overflow-wrap: anywhere; }
dialog.modal h3 { margin: 0 0 6px; font-size: 15px; }
.modal-x { position: sticky; top: -1rem; float: right; margin: -.5rem -.5rem 0 0; }
.modal-x button {
  background: none; border: 0; font-size: 26px; line-height: 1; padding: 4px 10px;
  color: var(--muted); cursor: pointer; border-radius: 8px;
}
.modal-x button:hover { color: var(--text); }
.modal-x button:focus-visible { outline: 3px solid var(--brand, var(--accent)); outline-offset: 2px; }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.modal-actions form { margin: 0; }
@media (max-width: 640px) { dialog.modal { padding: 1.25rem; max-height: 92vh; } }

/* Form caricato dentro la modale */
.modal-form-host { width: min(760px, 94vw); }
.modal-title { margin: 0 0 16px; font-size: 20px; }
.modal-loading { color: var(--muted); margin: 30px 0; text-align: center; }
/* Nella modale il form non ha bisogno del proprio riquadro: lo fornisce già la
   modale, e due bordi concentrici sembrano un errore. */
.modal-form-host form.card { border: 0; box-shadow: none; padding: 0; background: none; max-width: none; }

/* Form verticale dentro la modale (campi uno sotto l'altro con etichetta) */
.modal-form-stack { display: grid; gap: 12px; }
.modal-form-stack label { display: grid; gap: 5px; font-size: 13px; font-weight: 600; }
.modal-form-stack input, .modal-form-stack select, .modal-form-stack textarea {
  padding: 10px 12px; border-radius: 10px; font: inherit;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
