/* Screen-only layout: preserve the A4 production/print styles. */
@media screen {
  html { -webkit-text-size-adjust: 100%; }
  body, .app, main, .container, #adminArea, #clientArea { min-width: 0; }
  .hero, .grid, .form-row, .order-workspace, .product-grid, .cake-grid,
  .section-panel, .card, .login-card, .order-summary { min-width: 0; max-width: 100%; }
  .hero > *, .grid > *, .form-row > *, .order-workspace > *, .product-grid > *,
  .cake-grid > *, .admin-product-row > *, .delivery-line > * { min-width: 0; }
  input, select, textarea { font-size: 16px !important; max-width: 100%; }
  .field { min-width: 0; }
  input[type="date"], input[type="month"], input[type="time"] { min-width: 0; min-inline-size: 0; }
  button, .tab, .btn { white-space: normal; overflow-wrap: anywhere; }
  .topbar-inner { flex-wrap: wrap; }
  .brand, .section-panel-head, .summary-row { min-width: 0; }
  .brand, .section-panel-head { flex-wrap: wrap; }
  p, h1, h2, h3, summary, .notice, .summary-row, .product-name { overflow-wrap: anywhere; }
  .card { overflow-x: auto; }
  img { max-width: 100%; }
  dialog { box-sizing: border-box; max-width: calc(100vw - 24px) !important;
    max-height: calc(100dvh - 24px) !important; overflow: auto; padding: 20px;
    overflow-wrap: anywhere; min-width: 0; }
  dialog input, dialog select, dialog textarea { min-width: 0; }
}
@media screen and (max-width: 1024px) {
  .hero, .order-workspace { grid-template-columns: minmax(0, 1fr); }
  .order-summary { position: static; }
  .admin-product-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-product-row > :first-child { grid-column: 1 / -1; }
}
@media screen and (max-width: 600px) {
  .container { padding: 12px 10px 40px; }
  .card, .section-panel { padding: 14px; }
  .topbar-inner { gap: 8px; padding: 8px 10px; }
  .topbar .brand img { width: 44px !important; }
  .topbar .badge { font-size: 11px; }
  .topbar button { min-height: 40px; }
  .grid2, .grid3, .form-row, .cake-grid, .product-grid { grid-template-columns: minmax(0, 1fr); }
  .summary-row { flex-wrap: wrap; }
  .summary-row > * { min-width: 0; max-width: 100%; }
  .admin-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .admin-nav > button { width: 100%; min-height: 48px; border-radius: 12px; }
  .form-actions > button { flex: 1 1 160px; min-height: 44px; }
  .qty button { width: 42px; height: 42px; }
  .qty input { font-size: 16px; min-height: 42px; }
  dialog { width: calc(100vw - 24px) !important; padding: 16px !important; }
  .login-wrap { padding: 14px; }
  .login-card { padding: 20px; }
}
/* Telefono: pulsanti mai spezzati a lettera e tabelle come schede (etichette da mobile-tables.js). Desktop invariato. */
@media screen and (max-width: 600px) {
  button, .btn, .tab { overflow-wrap: normal; word-break: normal; }
  .btn { min-height: 44px; }
  table.m-card, table.m-card > thead, table.m-card > tbody, table.m-card > tfoot,
  table.m-card > * > tr, table.m-card > tr, table.m-card > * > tr > td, table.m-card > * > tr > th, table.m-card > tr > td {
    display: block; width: auto !important; min-width: 0 !important; max-width: 100%; }
  table.m-card { table-layout: auto !important; border: 0; }
  table.m-card > thead, table.m-card tr.m-head { display: none; }
  table.m-card > * > tr, table.m-card > tr { border: 1px solid var(--line, #e2e8f0); border-radius: 12px; padding: 8px 12px; margin: 0 0 10px; background: #fff; }
  table.m-card > * > tr > td, table.m-card > * > tr > th, table.m-card > tr > td {
    border: 0 !important; padding: 4px 0 !important; text-align: left !important; white-space: normal; position: static !important; }
  table.m-card td[data-label]:not([data-label=""])::before {
    content: attr(data-label); display: block; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: #64748b; }
  table.m-card td:empty { display: none; }
  table.m-card td > .btn:only-child, table.m-card td > button:only-child { width: 100%; }
}
/* Telefono: pulsanti senza stile proprio (giorni, «Apri foto», finestre) toccabili; schede HACCP a capo invece che nascoste di lato. */
@media screen and (max-width: 600px) {
  #adminArea button:not([class]):not(.qty *), dialog button:not([class]):not(.qty *) { min-height: 44px; padding: 8px 12px; border-radius: 10px; }
  #adminArea .haccp-tabs { flex-wrap: wrap; overflow-x: visible; }
  #adminArea .haccp-tabs .tab { white-space: normal; min-height: 40px; }
}
