/* Ciclo 063: rifiniture locali delle finestre e della Cassa. Le misure base del tema restano in app.html. */
.edit-dialog{
  box-sizing:border-box;
  max-width:calc(100vw - 24px);
  max-height:calc(100dvh - 24px);
  overflow-x:clip;
}
.edit-dialog :where(input,select,textarea,table,.edit-body,.edit-fields,.create-dialog-body,.csv-import-body){
  box-sizing:border-box;
  min-width:0;
  max-width:100%;
}
.edit-dialog :where(.edit-head,.edit-actions,.edit-foot){max-width:100%;box-sizing:border-box;flex-wrap:wrap}
.edit-dialog table{width:100%;table-layout:fixed}
.edit-dialog th,.edit-dialog td{overflow-wrap:anywhere}
.edit-dialog .catalog-variant-row{grid-template-columns:repeat(2,minmax(0,1fr))}
.edit-dialog .catalog-component-row{grid-template-columns:minmax(0,1fr) minmax(72px,100px) 40px}
.edit-dialog .catalog-component-variants{min-width:0}
.csv-import-dialog,.briefing-expanded-dialog{max-width:calc(100vw - 24px)}
.csv-import-body,#operationalImportPreview,#operationalImportResult{overflow-x:hidden}
.csv-import-body table{table-layout:fixed;width:100%}

/* Il richiamo superiore perde solo un poco di ingombro. */
.ai-trigger{min-width:160px;padding-inline:13px}
.ai-trigger img{width:136px}
.assistant-close-floating{position:absolute;z-index:2;right:10px;top:7px}
.assistant-status{padding-right:54px;min-height:48px}
.assistant-mascot{display:block;width:58px;height:auto;max-height:69px;object-fit:contain;margin:0 0 8px}
.assistant-ai-row{align-self:flex-start;display:flex;align-items:flex-start;gap:8px;max-width:94%}
.assistant-ai-row .assistant-message{max-width:calc(100% - 40px)}
.assistant-avatar{display:block;flex:0 0 32px;width:32px;height:32px;border-radius:50%;clip-path:circle(50%);object-fit:cover}
@media(max-width:1320px) and (min-width:821px){.ai-trigger{min-width:146px}.ai-trigger img{width:124px}}
@media(max-width:820px){.ai-trigger{min-width:46px}.ai-trigger img{width:29px}}

/* Cassa: a 1366×768 il dialogo e tutti i comandi restano nel riquadro visibile. */
#createDialog[data-flow="sale-new"]{width:min(1320px,calc(100vw - 24px));max-height:calc(100dvh - 16px)}
#createDialog[data-flow="sale-new"] .edit-head{padding:9px 14px}
#createDialog[data-flow="sale-new"] .create-dialog-body{max-height:none;overflow-y:hidden;padding:7px 14px 10px}
#createDialog[data-flow="sale-new"] #saleCreateCard>.feature-head{align-items:center;margin-bottom:1px}
#createDialog[data-flow="sale-new"] #saleCreateCard>.feature-head p{margin:0;font-size:12px}
#createDialog[data-flow="sale-new"] #saleCreateCard>.feature-head h2{margin:0;font-size:16px}
#createDialog[data-flow="sale-new"] label{margin:5px 0 3px;font-size:12px}
#createDialog[data-flow="sale-new"] :where(input,select,textarea){padding:7px 9px;font-size:14px;border-radius:8px}
#createDialog[data-flow="sale-new"] .amount-field input{padding:7px 58px 7px 9px;line-height:20px}
#createDialog[data-flow="sale-new"] .amount-currency{right:10px;top:50%;transform:translateY(-50%);line-height:1;font-size:13px}
#createDialog[data-flow="sale-new"] .sale-unit-field{position:relative;display:block;width:100%}
#createDialog[data-flow="sale-new"] .sale-unit-field input{width:100%;padding-right:38px;text-align:right}
#createDialog[data-flow="sale-new"] .sale-discount-unit{position:absolute;right:10px;top:50%;transform:translateY(-50%);line-height:1;color:var(--muted);font-size:13px;pointer-events:none}
#createDialog[data-flow="sale-new"] .row{gap:7px;flex-wrap:nowrap}
#createDialog[data-flow="sale-new"] .row>div{min-width:0}
#createDialog[data-flow="sale-new"] .sale-lookup-row>div{position:relative}
#createDialog[data-flow="sale-new"] .sale-lookup-row>div:first-child{flex:1.2}
#createDialog[data-flow="sale-new"] .sale-lookup-row>div:last-child{flex:1}
#createDialog[data-flow="sale-new"] .sale-lookup-row .msg{position:absolute;z-index:3;left:0;right:0;margin:2px 0 0;min-height:0;background:#fff}
#createDialog[data-flow="sale-new"] .sale-product-row>div{flex:1}
#createDialog[data-flow="sale-new"] .sale-product-row>div:nth-child(2){flex:1.55}
#createDialog[data-flow="sale-new"] .sale-product-row .sale-discount-kind{flex:0 0 140px}
#createDialog[data-flow="sale-new"] .sale-product-row .sale-discount-value{flex:0 0 100px}
#createDialog[data-flow="sale-new"] .sale-product-row>div:last-child{flex:0 0 126px!important}
#createDialog[data-flow="sale-new"] .sale-product-row>div:last-child .btn{width:100%;padding-inline:7px}
#createDialog[data-flow="sale-new"] .sale-variant-fields{gap:7px;margin:5px 0}
#createDialog[data-flow="sale-new"] #saleSubscriptionFields{margin-top:2px}
#createDialog[data-flow="sale-new"] #saleExchangePanel{padding:7px;margin:5px 0}
#createDialog[data-flow="sale-new"] .sale-cart-table{max-height:118px;overflow-y:auto!important;overflow-x:hidden!important;margin-top:7px;border:1px solid var(--line);border-radius:9px}
#createDialog[data-flow="sale-new"] .sale-cart-table table{table-layout:fixed;font-size:12px}
#createDialog[data-flow="sale-new"] .sale-cart-table th,#createDialog[data-flow="sale-new"] .sale-cart-table td{padding:4px 5px}
#createDialog[data-flow="sale-new"] .sale-cart-table th:nth-child(1){width:24%}
#createDialog[data-flow="sale-new"] .sale-cart-table th:nth-child(2){width:10%}
#createDialog[data-flow="sale-new"] .sale-cart-table th:nth-child(3){width:12%}
#createDialog[data-flow="sale-new"] .sale-cart-table th:nth-child(4){width:28%}
#createDialog[data-flow="sale-new"] .sale-cart-table th:nth-child(5){width:16%}
#createDialog[data-flow="sale-new"] .sale-cart-table th:nth-child(6){width:10%}
#createDialog[data-flow="sale-new"] .sale-line-discount{display:grid;grid-template-columns:115px 82px auto;justify-content:start;align-items:center;gap:4px}
#createDialog[data-flow="sale-new"] .sale-line-discount :where(select,input){padding:4px 5px}
#createDialog[data-flow="sale-new"] .sale-common-row{align-items:end}
#createDialog[data-flow="sale-new"] .sale-common-row>div:nth-child(1){flex:.55}
#createDialog[data-flow="sale-new"] .sale-common-row>.sale-client-field{flex:1.7;position:relative}
#createDialog[data-flow="sale-new"] .sale-client-picker{display:grid;grid-template-columns:minmax(0,1.25fr) minmax(0,1fr);gap:5px}
#createDialog[data-flow="sale-new"] .sale-client-results{position:absolute;z-index:4;left:0;right:0;margin:2px 0 0;min-height:0;background:#fff;box-shadow:0 8px 20px rgba(7,19,47,.15)}
#createDialog[data-flow="sale-new"] .sale-client-results:empty{display:none}
#createDialog[data-flow="sale-new"] .sale-client-results .btn{display:block;width:100%;text-align:left;white-space:normal}
#createDialog[data-flow="sale-new"] .sale-common-row>div:nth-child(3){flex:.75}
#createDialog[data-flow="sale-new"] .sale-common-row>div:nth-child(4){flex:1.1}
#createDialog[data-flow="sale-new"] .sale-total-row{align-items:end}
#createDialog[data-flow="sale-new"] .sale-total-row>div{min-width:0}
#createDialog[data-flow="sale-new"] .sale-total-row>div:last-child{flex:0 0 92px!important}
#createDialog[data-flow="sale-new"] .sale-total-row>div:last-child .btn{width:100%;padding-inline:7px}
#createDialog[data-flow="sale-new"] .kpi{padding:6px 8px;border-radius:9px}
#createDialog[data-flow="sale-new"] .kpi .lab{font-size:12px}
#createDialog[data-flow="sale-new"] .kpi .val{font-size:18px;margin-top:1px;text-align:right;white-space:nowrap}
#createDialog[data-flow="sale-new"] .msg{margin-top:4px;min-height:12px;font-size:12px}
@media(max-height:719px){
  #createDialog[data-flow="sale-new"] .create-dialog-body{max-height:calc(100dvh - 58px);overflow-y:auto}
}
@media(max-width:920px){
  #createDialog[data-flow="sale-new"] .row{flex-wrap:wrap}
  #createDialog[data-flow="sale-new"] .row>div{min-width:150px}
  #createDialog[data-flow="sale-new"] .create-dialog-body{max-height:calc(100dvh - 58px);overflow-y:auto}
}
