/* ---------- pannello laterale ---------- */
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer-backdrop { position: absolute; inset: 0; background: rgb(8 10 14 / 50%); backdrop-filter: blur(2px); }
.drawer-panel {
  position: absolute; inset: auto 0 0 0; max-height: 92dvh; background: var(--surface);
  border-radius: 20px 20px 0 0; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  padding-bottom: var(--sa-b);
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 1.125rem; }
/* Colonna semplice (non griglia): ogni blocco è alto quanto il suo contenuto, quindi la foto
   non può mai finire sopra il prezzo, a nessuna larghezza. Nessun blocco si schiaccia. */
/* overflow-x: Safari conta il margine interno anche dopo le barre in fondo, che arrivano già a filo del
   bordo: senza, la scheda scorreva di lato di 16 px (nessun contenuto resta fuori). */
.drawer-body { padding: 16px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 14px; }
.drawer-body > * { flex-shrink: 0; }
/* Riquadro fisso 4:3: la foto (anche se alta e stretta) ci sta intera e non esce mai dal riquadro. */
.detail-img {
  position: relative; aspect-ratio: 4 / 3; min-height: 0; border-radius: var(--radius); overflow: hidden;
  background: var(--surface-2); display: grid; place-items: center; color: var(--muted);
}
.detail-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }

.pill { font-size: 0.75rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.pill-on { background: var(--ok-soft); color: var(--ok); }
.pill-off { background: var(--warn-soft); color: var(--warn); }
/* Riquadro dei dati: nome del campo piccolo sopra, valore sotto, una riga per voce. */
.data { border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); overflow: hidden; }
.data-row { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 14px; color: inherit; text-decoration: none; }
.data-row + .data-row { border-top: 1px solid var(--line); }
.data-text { flex: 1; min-width: 0; display: grid; gap: 3px; }
.data-text small { font-size: .6875rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.data-text b { font-size: 1.0625rem; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; white-space: pre-line; }
.data-call { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 0 16px; border-radius: 12px; background: var(--ok-soft); color: var(--ok); font-weight: 700; }
.data-call svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
a.data-row:hover { background: var(--surface-3); }
.detail-list { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 10px 14px; font-size: 0.875rem; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; }
.tag { display: inline-block; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px 8px; margin: 0 4px 4px 0; font-size: 0.8125rem; }
.note { font-size: 0.8125rem; color: var(--muted); background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; margin: 0; }
.log-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.log { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; display: grid; gap: 6px; }
.log-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.log pre { margin: 0; font-size: 0.8125rem; white-space: pre-wrap; word-break: break-all; background: var(--surface-2); padding: 8px; border-radius: 8px; }

/* ---------- finestra ---------- */
.modal { border: 0; border-radius: 18px; padding: 0; background: transparent; width: min(440px, calc(100vw - 32px)); color: var(--text); }
.modal::backdrop { background: rgb(8 10 14 / 55%); backdrop-filter: blur(2px); }
.modal-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; display: grid; gap: 14px; box-shadow: var(--shadow-lg); }
.modal-card h2 { margin: 0; font-size: 1.1875rem; }
#modal-body { display: grid; gap: 12px; }
#modal-body p { margin: 0; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  /* nelle finestre lunghe Salva e Annulla restano in vista */
  position: sticky; bottom: 0; z-index: 2; margin: 0 -20px -20px; padding: 12px 20px 20px;
  background: var(--surface); border-radius: 0 0 17px 17px;
}

/* ---------- attesa ---------- */
.loading {
  position: fixed; inset: 0; z-index: 70; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: 24px; text-align: center;
}
.loading p { margin: 0; font-weight: 600; color: var(--muted); max-width: 320px; }
.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
  .dish.flash { animation: none; }
}
.load-error {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 24px 20px; display: grid; gap: 10px; justify-items: start;
}
.load-error p { margin: 0; }
