/* ─── Material You 2025 Token System ─────────────────────────────── */
    /* `color-scheme` dichiarato anche qui: vale dal primo paint (prima che il
       JS giri) e fa si' che il canvas del browser — inclusa la fascia sotto il
       notch con viewport-fit=cover — usi i colori del tema invece del nero. */
    :root {
      color-scheme: dark;
      --md-sys-color-background:            #0f1117;
      --md-sys-color-surface:               #141920;
      --md-sys-color-surface-container-low: #191f28;
      --md-sys-color-surface-container:     #1e2530;
      --md-sys-color-surface-container-high:#242c38;
      --md-sys-color-surface-variant:       #2a3340;
      --md-sys-color-outline:               #38424f;
      --md-sys-color-outline-variant:       #2e3844;
      --md-sys-color-primary:               #a8c7fa;
      --md-sys-color-primary-container:     #0842a0;
      --md-sys-color-on-primary:            #002b6b;
      --md-sys-color-on-primary-container:  #d3e3fd;
      --md-sys-color-secondary:             #7fcfbd;
      --md-sys-color-secondary-container:   #00504a;
      --md-sys-color-on-secondary-container:#b2dfdb;
      --md-sys-color-error:                 #ffb3ae;
      --md-sys-color-error-container:       #680003;
      --md-sys-color-on-error-container:    #ffdad6;
      --md-sys-color-tertiary:              #f6c843;
      --md-sys-color-tertiary-container:    #503d00;
      --md-sys-color-on-surface:            #dde3ea;
      --md-sys-color-on-surface-variant:    #8d9199;
      --md-shape-corner-extra-small: 4px;
      --md-shape-corner-small:       8px;
      --md-shape-corner-medium:      12px;
      --md-shape-corner-large:       16px;
      --md-shape-corner-extra-large: 28px;
      --md-shape-corner-full:        9999px;
      --md-elevation-1: 0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
      --md-elevation-2: 0 3px 8px rgba(0,0,0,.32);
      --md-elevation-3: 0 6px 20px rgba(0,0,0,.4);
      --md-motion-standard:   cubic-bezier(.2,0,0,1);
      --md-motion-emphasized: cubic-bezier(.2,0,0,1.4);
      --md-motion-duration-short:  200ms;
      --md-motion-duration-medium: 300ms;
      --md-motion-duration-long:   450ms;
    }

    /* ─── Light theme (M3 tonal surfaces) ─────────────────────────── */
    [data-theme="light"] {
      color-scheme: light;
      --md-sys-color-background:            #f5f7fb;
      --md-sys-color-surface:               #fafbfe;
      --md-sys-color-surface-container-low: #eef1f7;
      --md-sys-color-surface-container:     #e6eaf1;
      --md-sys-color-surface-container-high:#dfe4ec;
      --md-sys-color-surface-variant:       #d8dee8;
      --md-sys-color-outline:               #74777f;
      --md-sys-color-outline-variant:       #c4c8d0;
      --md-sys-color-primary:               #0b57d0;
      --md-sys-color-primary-container:     #d3e3fd;
      --md-sys-color-on-primary:            #ffffff;
      --md-sys-color-on-primary-container:  #041e49;
      --md-sys-color-secondary:             #006a60;
      --md-sys-color-secondary-container:   #cde8e1;
      --md-sys-color-on-secondary-container:#00201a;
      --md-sys-color-error:                 #ba1a1a;
      --md-sys-color-error-container:       #ffdad6;
      --md-sys-color-on-error-container:    #410002;
      --md-sys-color-tertiary:              #8a5a00;
      --md-sys-color-tertiary-container:    #ffe08c;
      --md-sys-color-on-tertiary-container: #2b1b00;
      --md-sys-color-on-surface:            #191c20;
      --md-sys-color-on-surface-variant:    #44474e;
    }

    [data-theme="light"] .top-app-bar { background: rgba(245,247,251,.85); }
    [data-theme="light"] .btn-scrape:hover:not(:disabled) { background: #0a4fbd; }
    [data-theme="light"] .badge-deal { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); border-color: rgba(0,106,96,.35); }
    [data-theme="light"] .badge-fake { background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); border-color: rgba(186,26,26,.3); }
    [data-theme="light"] .badge-mild { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); border-color: rgba(11,87,208,.3); }
    [data-theme="light"] .seg-option:hover:not(.active) { background: rgba(0,0,0,.05); }
    [data-theme="light"] .btn-outline:hover { background: rgba(0,0,0,.05); }

    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    /* Anche il canvas del documento prende il colore del tema: con
       viewport-fit=cover l'area del notch/status bar e' dipinta dalla pagina,
       e un `html` trasparente lascia vedere il fondo nero della webview
       (stessa famiglia di problema della .top-app-bar senza safe-area). */
    html {
      scroll-behavior: smooth;
      background: var(--md-sys-color-background);
    }

    /* ─── Nessun pull-to-refresh / rimbalzo del browser ────────────────
       ATTENZIONE: `overscroll-behavior-y: none` NON va messo su html/body.
       In Chrome mobile blocca del tutto lo scroll naturale della pagina
       (rotellina e swipe restano a scrollY = 0: la pagina sembra morta),
       mentre scrollTo() da JS continua a funzionare — fuorviante in debug.
       Sul root si lascia `auto`; il rimbalzo/PTR si evita con `contain`
       sui contenitori scrollabili interni, dove serve davvero. */
    html, body { overscroll-behavior-y: auto; }

    body {
      font-family: 'Google Sans', 'Roboto', system-ui, sans-serif;
      background: var(--md-sys-color-background);
      color: var(--md-sys-color-on-surface);
      line-height: 1.5;
      min-height: 100vh;
    }

    /* Contenitori scrollabili: l'overscroll resta locale, non arriva al root */
    .category-list,
    .queue-body,
    .queue-history-list,
    .cart-items-list,
    .full-modal,
    .full-modal-body,
    .page-sidebar,
    .dialog,
    .cart-drawer,
    .pwa-sheet { overscroll-behavior-y: contain; }

    /* Top App Bar */
    .top-app-bar {
      position: sticky; top: 0; z-index: 900;
      background: rgba(15,17,23,.85);
      backdrop-filter: blur(20px) saturate(180%);
      -webkit-backdrop-filter: blur(20px) saturate(180%);
      border-bottom: 1px solid var(--md-sys-color-outline-variant);
      height: 64px; display: flex; align-items: center;
      padding: 0 24px; gap: 16px;
      /* Con viewport-fit=cover la pagina arriva sotto il notch/status bar:
         la top-bar dipinge anche quella fascia (altrimenti resta nera, perche'
         e' il sistema a riempirla) e il suo contenuto viene spinto giu' di
         `safe-area-inset-top`. `box-sizing: border-box` e' gia' globale, quindi
         l'altezza segue automaticamente (content-box + padding). */
      padding-top: env(safe-area-inset-top, 0px);
      height: calc(64px + env(safe-area-inset-top, 0px));
    }

    .app-bar-logo {
      width: 36px; height: 36px;
      border-radius: var(--md-shape-corner-medium);
      background: linear-gradient(135deg, #4285F4 0%, #0F9D58 100%);
      display: flex; align-items: center; justify-content: center;
      flex-shrink: 0;
    }
    .app-bar-logo svg { width: 20px; height: 20px; fill: white; }

    .app-bar-title {
      font-family: 'Google Sans Display', 'Google Sans', sans-serif;
      font-size: 1.25rem; font-weight: 500; letter-spacing: -.25px;
      color: var(--md-sys-color-on-surface); flex: 1;
    }
    .app-bar-title em { font-style: normal; color: var(--md-sys-color-primary); }

    .app-bar-pill {
      background: var(--md-sys-color-surface-container-high);
      border: 1px solid var(--md-sys-color-outline-variant);
      border-radius: var(--md-shape-corner-full);
      padding: 6px 16px; font-size: .8rem; font-weight: 500;
      color: var(--md-sys-color-on-surface-variant); white-space: nowrap;
    }

    .btn-scrape {
      display: inline-flex; align-items: center; gap: 8px;
      height: 40px; padding: 0 20px; flex-shrink: 0;
      border-radius: var(--md-shape-corner-full);
      border: none; cursor: pointer;
      background: var(--md-sys-color-primary);
      color: var(--md-sys-color-on-primary);
      font-family: inherit; font-size: .875rem; font-weight: 600;
      transition: background var(--md-motion-duration-short) var(--md-motion-standard),
                  opacity var(--md-motion-duration-short);
    }
    .btn-scrape:hover:not(:disabled) { background: #b9d2fc; }
    .btn-scrape:disabled { opacity: .55; cursor: not-allowed; }
    .btn-scrape .spin {
      display: inline-block; width: 14px; height: 14px;
      border: 2px solid rgba(0,43,107,.35); border-top-color: var(--md-sys-color-on-primary);
      border-radius: 50%; animation: spin 0.8s linear infinite;
    }
    @keyframes spin { to { transform: rotate(360deg); } }

    .theme-seg {
      display: flex; align-items: center; flex-shrink: 0;
      height: 40px;
      border: 1.5px solid var(--md-sys-color-outline);
      border-radius: var(--md-shape-corner-full); overflow: hidden;
    }
    .theme-opt {
      width: 40px; height: 100%;
      display: flex; align-items: center; justify-content: center;
      background: transparent; border: none; cursor: pointer;
      border-right: 1px solid var(--md-sys-color-outline);
      color: var(--md-sys-color-on-surface-variant);
      transition: background var(--md-motion-duration-short), color var(--md-motion-duration-short);
    }
    .theme-opt:last-child { border-right: none; }
    .theme-opt svg { width: 16px; height: 16px; }
    .theme-opt:hover { background: rgba(255,255,255,.05); color: var(--md-sys-color-on-surface); }
    .theme-opt.active { background: rgba(168,199,250,.16); color: var(--md-sys-color-primary); }
    [data-theme="light"] .theme-opt:hover { background: rgba(0,0,0,.05); }

    /* Page Shell */
    .page { max-width: 1440px; margin: 0 auto; padding: 28px 24px 80px; }

    /* Stats Grid */
    .stats-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
      gap: 12px; margin-bottom: 28px;
    }

    .stat-card {
      background: var(--md-sys-color-surface-container-low);
      border: 1px solid var(--md-sys-color-outline-variant);
      border-radius: var(--md-shape-corner-extra-large);
      padding: 20px 22px; display: flex; flex-direction: column; gap: 10px;
      position: relative; overflow: hidden; cursor: default;
      transition: background var(--md-motion-duration-short) var(--md-motion-standard),
                  transform var(--md-motion-duration-short) var(--md-motion-emphasized);
    }
    .stat-card::before {
      content: ''; position: absolute; inset: 0;
      background: radial-gradient(ellipse at 80% 20%, var(--card-tint, rgba(168,199,250,.06)) 0%, transparent 70%);
      pointer-events: none;
    }
    .stat-card:hover { transform: translateY(-3px); background: var(--md-sys-color-surface-container); }

    .stat-icon {
      width: 36px; height: 36px;
      border-radius: var(--md-shape-corner-medium);
      display: flex; align-items: center; justify-content: center; font-size: 1rem;
    }
    .stat-label { font-size: .76rem; font-weight: 500; letter-spacing: .3px; color: var(--md-sys-color-on-surface-variant); }
    .stat-value {
      font-family: 'Google Sans Display', sans-serif;
      font-size: 2rem; font-weight: 700; line-height: 1; letter-spacing: -1px;
    }

    /* Search Panel */
    .search-panel {
      background: var(--md-sys-color-surface-container-low);
      border: 1px solid var(--md-sys-color-outline-variant);
      border-radius: var(--md-shape-corner-extra-large);
      padding: 16px 20px; margin-bottom: 24px;
      display: flex; flex-direction: column; gap: 14px;
    }

    .search-field {
      display: flex; align-items: center; gap: 12px;
      background: var(--md-sys-color-surface-container);
      border: 1.5px solid var(--md-sys-color-outline);
      border-radius: var(--md-shape-corner-full);
      padding: 0 20px; height: 52px;
      transition: border-color var(--md-motion-duration-short) var(--md-motion-standard),
                  box-shadow var(--md-motion-duration-short) var(--md-motion-standard);
    }
    .search-field:focus-within {
      border-color: var(--md-sys-color-primary);
      box-shadow: 0 0 0 3px rgba(168,199,250,.18);
    }
    .search-field svg { flex-shrink: 0; }

    .search-input {
      flex: 1; background: transparent; border: none; outline: none;
      color: var(--md-sys-color-on-surface); font-family: inherit; font-size: 1rem;
    }
    .search-input::placeholder { color: var(--md-sys-color-on-surface-variant); }

    .controls-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

    .m3-select {
      appearance: none;
      background: var(--md-sys-color-surface-container);
      border: 1.5px solid var(--md-sys-color-outline);
      border-radius: var(--md-shape-corner-full);
      color: var(--md-sys-color-on-surface);
      font-family: inherit; font-size: .875rem; font-weight: 500;
      padding: 8px 36px 8px 16px; outline: none; cursor: pointer;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='%238d9199'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
      background-repeat: no-repeat; background-position: right 10px center;
      transition: border-color var(--md-motion-duration-short);
    }
    .m3-select:focus { border-color: var(--md-sys-color-primary); }

    .filter-chip {
      display: inline-flex; align-items: center; gap: 6px;
      height: 34px; padding: 0 16px;
      border-radius: var(--md-shape-corner-full);
      border: 1.5px solid var(--md-sys-color-outline);
      background: transparent; color: var(--md-sys-color-on-surface-variant);
      font-family: inherit; font-size: .875rem; font-weight: 500;
      cursor: pointer; white-space: nowrap;
      transition: background var(--md-motion-duration-short) var(--md-motion-standard),
                  border-color var(--md-motion-duration-short),
                  color var(--md-motion-duration-short);
    }
    .filter-chip:hover { background: rgba(168,199,250,.08); border-color: var(--md-sys-color-primary); color: var(--md-sys-color-primary); }
    .filter-chip.active { background: rgba(168,199,250,.14); border-color: var(--md-sys-color-primary); color: var(--md-sys-color-primary); }
    .filter-chip.chip-deals.active { background: rgba(127,207,189,.14); border-color: var(--md-sys-color-secondary); color: var(--md-sys-color-secondary); }
    .filter-chip.chip-fake.active  { background: rgba(255,179,174,.14); border-color: var(--md-sys-color-error); color: var(--md-sys-color-error); }
    .filter-chip.chip-new-discount.active { background: rgba(246,200,67,.18); border-color: var(--md-sys-color-tertiary); color: var(--md-sys-color-tertiary); }
    .filter-chip.chip-unavailable { border-style: solid; }
    /* attivo ben riconoscibile come gli altri chip (prima tratteggiato e grigio: sembrava spento) */
    .filter-chip.chip-unavailable.active { background: var(--md-sys-color-surface-container-high); border-color: var(--md-sys-color-on-surface); color: var(--md-sys-color-on-surface); border-style: solid; font-weight: 600; }
    .badge-new-discount { background: rgba(246,200,67,.2); color: var(--md-sys-color-tertiary); border: 1px solid rgba(246,200,67,.5); }
    .badge-unavailable { background: rgba(128,128,128,.15); color: var(--md-sys-color-on-surface-variant); border: 1px solid rgba(128,128,128,.35); }
    .prod-card.card-unavailable, tr.card-unavailable { opacity: 0.6; }
    .prod-card.card-unavailable .prod-img-wrap img, tr.card-unavailable img { filter: grayscale(60%); }


    .segmented-btn {
      display: flex; margin-left: auto;
      border: 1.5px solid var(--md-sys-color-outline);
      border-radius: var(--md-shape-corner-full); overflow: hidden;
    }
    .seg-option {
      display: flex; align-items: center; justify-content: center; gap: 6px;
      padding: 0 18px; height: 34px;
      background: transparent; border: none;
      border-right: 1px solid var(--md-sys-color-outline);
      color: var(--md-sys-color-on-surface-variant);
      font-family: inherit; font-size: .875rem; font-weight: 500; cursor: pointer;
      transition: background var(--md-motion-duration-short), color var(--md-motion-duration-short);
    }
    .seg-option:last-child { border-right: none; }
    .seg-option.active { background: rgba(168,199,250,.16); color: var(--md-sys-color-primary); }
    .seg-option:hover:not(.active) { background: rgba(255,255,255,.05); }

    /* Results Bar */
    .results-bar { display: flex; align-items: center; margin-bottom: 16px; }
    .results-count { font-size: .85rem; color: var(--md-sys-color-on-surface-variant); font-weight: 500; }

    /* Product Grid */
    .product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

    .prod-card {
      content-visibility: auto;
      contain-intrinsic-size: 280px 380px;
      background: var(--md-sys-color-surface-container-low);
      border: 1px solid var(--md-sys-color-outline-variant);
      border-radius: var(--md-shape-corner-extra-large);
      display: flex; flex-direction: column; overflow: hidden;
      transition: background var(--md-motion-duration-short) var(--md-motion-standard),
                  transform var(--md-motion-duration-medium) var(--md-motion-emphasized),
                  border-color var(--md-motion-duration-short),
                  box-shadow var(--md-motion-duration-medium);
    }
    .prod-card:hover {
      background: var(--md-sys-color-surface-container);
      border-color: var(--md-sys-color-primary);
      transform: translateY(-4px);
      box-shadow: var(--md-elevation-3);
    }

    .prod-img-wrap {
      position: relative; background: #fff;
      height: 168px; display: flex; align-items: center; justify-content: center; overflow: hidden;
    }
    .prod-img-wrap a { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; padding: 12px; }
    .prod-img-wrap img {
      max-height: 100%; max-width: 100%; object-fit: contain;
      transition: transform var(--md-motion-duration-medium) var(--md-motion-emphasized);
    }
    .prod-card:hover .prod-img-wrap img { transform: scale(1.07); }

    .badge-overlay {
      position: absolute; top: 10px; right: 10px; left: 10px;
      display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
      pointer-events: none;
    }

    .m3-badge {
      display: inline-flex; align-items: center; gap: 4px;
      padding: 4px 10px; border-radius: var(--md-shape-corner-full);
      font-size: .72rem; font-weight: 700; letter-spacing: .3px;
      backdrop-filter: blur(8px);
    }
    .badge-deal { background: rgba(0,80,74,.85); color: var(--md-sys-color-secondary); border: 1px solid rgba(127,207,189,.4); }
    .badge-fake { background: rgba(104,0,3,.85);  color: var(--md-sys-color-error);     border: 1px solid rgba(255,179,174,.4); }
    .badge-mild { background: rgba(8,66,160,.65);  color: var(--md-sys-color-primary);   border: 1px solid rgba(168,199,250,.4); }

    .prod-body { padding: 14px 16px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
    .prod-brand { font-size: .7rem; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--md-sys-color-tertiary); }
    .prod-title { font-size: .925rem; font-weight: 500; color: var(--md-sys-color-on-surface); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    .prod-title a { color: inherit; text-decoration: none; transition: color var(--md-motion-duration-short); }
    .prod-title a:hover { color: var(--md-sys-color-primary); }

    .price-area { display: flex; align-items: baseline; gap: 8px; margin-top: 2px; flex-wrap: wrap; }
    .price-final { font-family: 'Google Sans Display', sans-serif; font-size: 1.55rem; font-weight: 700; color: var(--md-sys-color-secondary); letter-spacing: -0.5px; }
    .price-list  { font-size: .9rem; color: var(--md-sys-color-on-surface-variant); text-decoration: line-through; }
    .price-unit  { font-size: .78rem; font-weight: 600; color: var(--md-sys-color-primary); background: rgba(168,199,250,.12); padding: 2px 8px; border-radius: var(--md-shape-corner-full); margin-left: auto; white-space: nowrap; }
    [data-theme="light"] .price-unit { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); }
    .price-meta  { font-size: .74rem; color: var(--md-sys-color-on-surface-variant); line-height: 1.6; }

    .prod-actions { display: flex; gap: 8px; padding: 0 16px 14px; }

    .btn-tonal {
      flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
      height: 40px; padding: 0 16px;
      border-radius: var(--md-shape-corner-large);
      border: 1.5px solid var(--md-sys-color-outline);
      background: rgba(168,199,250,.08); color: var(--md-sys-color-primary);
      font-family: inherit; font-size: .85rem; font-weight: 500;
      cursor: pointer; text-decoration: none;
      transition: background var(--md-motion-duration-short), border-color var(--md-motion-duration-short);
    }
    .btn-tonal:hover { background: rgba(168,199,250,.18); border-color: var(--md-sys-color-primary); }

    .btn-outline {
      display: flex; align-items: center; justify-content: center; gap: 6px;
      height: 40px; padding: 0 16px;
      border-radius: var(--md-shape-corner-large);
      border: 1.5px solid var(--md-sys-color-outline);
      background: transparent; color: var(--md-sys-color-on-surface-variant);
      font-family: inherit; font-size: .85rem; font-weight: 500;
      cursor: pointer; text-decoration: none;
      transition: background var(--md-motion-duration-short), color var(--md-motion-duration-short);
    }
    .btn-outline:hover { background: rgba(255,255,255,.06); color: var(--md-sys-color-on-surface); }

    /* Table */
    .table-container {
      display: none;
      background: var(--md-sys-color-surface-container-low);
      border: 1px solid var(--md-sys-color-outline-variant);
      border-radius: var(--md-shape-corner-extra-large);
      overflow: hidden; overflow-x: auto;
    }
    table { width: 100%; border-collapse: collapse; font-size: .875rem; }
    thead th {
      background: var(--md-sys-color-surface-container);
      color: var(--md-sys-color-on-surface-variant);
      font-weight: 600; font-size: .72rem; letter-spacing: .8px; text-transform: uppercase;
      padding: 14px 16px; border-bottom: 1px solid var(--md-sys-color-outline-variant);
      text-align: left; white-space: nowrap;
    }
    tbody td { padding: 12px 16px; border-bottom: 1px solid var(--md-sys-color-outline-variant); vertical-align: middle; }
    tbody tr:last-child td { border-bottom: none; }
    tbody tr {
      content-visibility: auto;
      contain-intrinsic-size: 52px;
      transition: background var(--md-motion-duration-short);
    }
    tbody tr:hover td { background: var(--md-sys-color-surface-container); }
    .tbl-thumb { width: 44px; height: 44px; object-fit: contain; background: white; border-radius: var(--md-shape-corner-medium); padding: 3px; }

    /* Empty State */
    .empty-state { grid-column: 1/-1; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 64px 24px; color: var(--md-sys-color-on-surface-variant); text-align: center; }
    .empty-state .icon { font-size: 3rem; }
    .empty-state p { font-size: .95rem; }

    /* Snackbar */
    #snackbar {
      position: fixed; bottom: 28px; left: 50%;
      transform: translateX(-50%) translateY(80px);
      background: var(--md-sys-color-surface-container-high);
      color: var(--md-sys-color-on-surface);
      border-radius: var(--md-shape-corner-extra-small);
      padding: 14px 20px; font-size: .9rem;
      box-shadow: var(--md-elevation-2); z-index: 1100;
      transition: transform var(--md-motion-duration-medium) var(--md-motion-emphasized);
      pointer-events: none;
    }
    #snackbar.show { transform: translateX(-50%) translateY(0); }

    /* Dialog */
    .dialog-overlay {
      display: none; position: fixed; inset: 0;
      background: rgba(0,0,0,.6);
      backdrop-filter: blur(12px) saturate(150%);
      -webkit-backdrop-filter: blur(12px) saturate(150%);
      z-index: 1000; align-items: center; justify-content: center; padding: 24px;
    }
    .dialog-overlay.open { display: flex; }

    .dialog {
      background: var(--md-sys-color-surface-container);
      border: 1px solid var(--md-sys-color-outline-variant);
      border-radius: var(--md-shape-corner-extra-large);
      max-width: 860px; width: 100%; padding: 28px 32px 32px;
      position: relative; box-shadow: var(--md-elevation-3);
      animation: dialog-enter var(--md-motion-duration-medium) var(--md-motion-emphasized);
    }
    @keyframes dialog-enter {
      from { opacity: 0; transform: scale(.94) translateY(16px); }
      to   { opacity: 1; transform: scale(1)   translateY(0);    }
    }

    .dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
    .dialog-title  { font-size: 1.15rem; font-weight: 600; color: var(--md-sys-color-on-surface); line-height: 1.3; }
    .dialog-subtitle { font-size: .8rem; color: var(--md-sys-color-on-surface-variant); margin-top: 3px; }

    .dialog-close {
      width: 36px; height: 36px; border-radius: 50%;
      border: 1px solid var(--md-sys-color-outline);
      background: var(--md-sys-color-surface-container-high);
      color: var(--md-sys-color-on-surface-variant);
      font-size: 1.1rem; cursor: pointer;
      display: flex; align-items: center; justify-content: center; flex-shrink: 0;
      transition: background var(--md-motion-duration-short);
    }
    .dialog-close:hover { background: var(--md-sys-color-surface-variant); color: var(--md-sys-color-on-surface); }

    .chart-wrap { position: relative; height: 340px; margin-top: 8px; }

    /* ─── Layout: main content + right sidebar ───────────────────── */
    .page-layout {
      max-width: 1600px; margin: 0 auto; padding: 28px 24px 80px;
      display: flex; gap: 24px; align-items: flex-start;
    }
    .page-main { flex: 1; min-width: 0; }

    .page-sidebar {
      width: 280px; flex-shrink: 0;
      position: sticky; top: 88px;
      max-height: calc(100vh - 112px);
      display: flex; flex-direction: column;
    }
    .sidebar-card {
      background: var(--md-sys-color-surface-container-low);
      border: 1px solid var(--md-sys-color-outline-variant);
      border-radius: var(--md-shape-corner-extra-large);
      padding: 16px; display: flex; flex-direction: column; gap: 6px; min-height: 0;
    }
    .sidebar-title {
      font-size: .76rem; font-weight: 700; letter-spacing: .8px;
      text-transform: uppercase; color: var(--md-sys-color-on-surface-variant);
      padding: 0 4px 6px; white-space: nowrap;
    }
    .cat-search-wrap {
      position: relative; margin-bottom: 8px;
    }
    .cat-search-icon {
      position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
      pointer-events: none; opacity: .5; color: var(--md-sys-color-on-surface-variant);
    }
    .cat-search-input {
      width: 100%; padding: 7px 10px 7px 30px;
      background: var(--md-sys-color-surface-container);
      border: 1px solid var(--md-sys-color-outline-variant);
      border-radius: var(--md-shape-corner-medium);
      color: var(--md-sys-color-on-surface);
      font-size: .8rem; font-family: inherit; outline: none;
      transition: border-color var(--md-motion-duration-short);
    }
    .cat-search-input:focus { border-color: var(--md-sys-color-primary); }
    .cat-search-input::placeholder { color: var(--md-sys-color-on-surface-variant); opacity: .7; }

    .category-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; min-height: 0; padding-right: 4px; }
    
    /* flex-shrink: 0 = le righe dell'albero non possono essere compresse.
       Senza questo, qualsiasi cosa che renda il nodo un contenitore con
       overflow != visible (es. la classe .ripple-host) azzera la min-size
       automatica dei flex item e il nodo collassa a altezza 0. */
    .cat-tree-node { display: flex; flex-direction: column; flex: 0 0 auto; }
    .cat-node-row {
      display: flex; align-items: center; gap: 2px; width: 100%;
      border-radius: var(--md-shape-corner-medium);
      padding: 2px 4px 2px 2px;
      transition: background var(--md-motion-duration-short);
    }
    .cat-node-row:hover { background: var(--md-sys-color-surface-container); }
    .cat-node-row.active {
      background: rgba(168,199,250,.15);
      color: var(--md-sys-color-primary);
    }
    [data-theme="light"] .cat-node-row.active {
      background: var(--md-sys-color-primary-container);
      color: var(--md-sys-color-on-primary-container);
    }

    .cat-toggle-btn {
      width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
      background: transparent; border: none; cursor: pointer;
      color: var(--md-sys-color-on-surface-variant);
      border-radius: 4px; flex-shrink: 0;
      transition: transform var(--md-motion-duration-short), color var(--md-motion-duration-short);
    }
    .cat-toggle-btn:hover { color: var(--md-sys-color-on-surface); background: rgba(255,255,255,.06); }
    .cat-toggle-btn.expanded { transform: rotate(90deg); }
    .cat-toggle-btn.placeholder { visibility: hidden; pointer-events: none; }

    .cat-btn {
      flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 6px;
      padding: 6px 6px 6px 0; background: transparent; border: none; cursor: pointer;
      color: inherit; font-family: inherit; font-size: .84rem; font-weight: 500;
      text-align: left; min-width: 0; border-radius: 4px;
    }
    .cat-btn span.cat-label {
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .cat-bullet {
      font-size: .7rem; opacity: .4; margin-right: 4px; flex-shrink: 0;
    }
    .cat-count {
      font-size: .68rem; padding: 1px 6px; border-radius: 10px;
      background: var(--md-sys-color-surface-container-high);
      color: var(--md-sys-color-on-surface-variant);
      font-weight: 600; flex-shrink: 0;
    }
    .cat-node-row.active .cat-count {
      background: rgba(168,199,250,.25);
      color: var(--md-sys-color-primary);
    }
    [data-theme="light"] .cat-node-row.active .cat-count {
      background: rgba(11,87,208,.15);
      color: var(--md-sys-color-primary);
    }

    .cat-subtree {
      display: none;
      padding-left: 12px;
      border-left: 1.5px solid var(--md-sys-color-outline-variant);
      margin-left: 11px;
      margin-top: 1px;
      margin-bottom: 2px;
      flex-direction: column;
      gap: 1px;
    }
    .cat-subtree.open { display: flex; }

    /* ─── Sortable table header ──────────────────────────────────── */
    .th-sort { cursor: pointer; user-select: none; }
    .th-sort::after { content: ''; margin-left: 4px; opacity: .35; font-size: .8em; }
    .th-sort.sort-asc::after  { content: '↑'; opacity: 1; }
    .th-sort.sort-desc::after { content: '↓'; opacity: 1; }



    /* ─── Live Scraping Progress Banner ──────────────────────────── */
    .scrape-banner {
      background: var(--md-sys-color-surface-container);
      border: 1.5px solid var(--md-sys-color-primary);
      border-radius: var(--md-shape-corner-extra-large);
      padding: 16px 20px; margin-bottom: 24px;
      display: flex; flex-direction: column; gap: 10px;
      box-shadow: 0 4px 24px rgba(8,66,160,.2);
      animation: banner-enter var(--md-motion-duration-medium) var(--md-motion-emphasized);
    }
    @keyframes banner-enter {
      from { opacity: 0; transform: translateY(-8px); }
      to   { opacity: 1; transform: translateY(0); }
    }
    .scrape-banner-top {
      display: flex; align-items: center; justify-content: space-between; gap: 12px;
    }
    .scrape-live-indicator { display: flex; align-items: center; gap: 9px; }
    .pulse-dot {
      width: 10px; height: 10px; border-radius: 50%;
      background: #22c55e;
      box-shadow: 0 0 0 0 rgba(34,197,94,.7);
      animation: pulse-ring 1.8s infinite cubic-bezier(.45,0,.55,1);
    }
    @keyframes pulse-ring {
      0%   { transform: scale(.95); box-shadow: 0 0 0 0 rgba(34,197,94,.7); }
      70%  { transform: scale(1);   box-shadow: 0 0 0 8px rgba(34,197,94,0); }
      100% { transform: scale(.95); box-shadow: 0 0 0 0 rgba(34,197,94,0); }
    }
    .scrape-banner-title {
      font-weight: 600; font-size: .95rem; color: var(--md-sys-color-on-surface);
    }
    .scrape-pct-badge {
      font-family: 'Google Sans Display', sans-serif;
      font-size: 1.15rem; font-weight: 700; color: var(--md-sys-color-primary);
      background: rgba(168,199,250,.16); padding: 3px 12px;
      border-radius: var(--md-shape-corner-full); letter-spacing: -.3px;
    }
    [data-theme="light"] .scrape-pct-badge { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); }

    .scrape-progress-track {
      width: 100%; height: 9px;
      background: var(--md-sys-color-surface-container-high);
      border-radius: 6px; overflow: hidden; position: relative;
    }
    .scrape-progress-fill {
      height: 100%;
      background: linear-gradient(90deg, #3b82f6, #60a5fa, #93c5fd);
      border-radius: 6px; transition: width .35s ease; position: relative;
    }
    .scrape-progress-fill::after {
      content: ''; position: absolute; inset: 0;
      background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent);
      animation: progress-shimmer 1.5s infinite;
    }
    @keyframes progress-shimmer {
      0%   { transform: translateX(-100%); }
      100% { transform: translateX(100%); }
    }

    .scrape-banner-details {
      display: flex; align-items: center; justify-content: space-between;
      font-size: .82rem; color: var(--md-sys-color-on-surface-variant);
      gap: 12px; flex-wrap: wrap;
    }
    .scrape-current-cat {
      display: flex; align-items: center; gap: 6px;
      font-weight: 500; color: var(--md-sys-color-on-surface);
      max-width: 68%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .scrape-stats-row {
      display: flex; align-items: center; gap: 8px; font-weight: 500;
    }

    /* Loading state box */
    .loading-state-box {
      grid-column: 1 / -1;
      display: flex; flex-direction: column; align-items: center; justify-content: center;
      gap: 14px; padding: 56px 20px;
      background: var(--md-sys-color-surface-container-low);
      border: 1px solid var(--md-sys-color-outline-variant);
      border-radius: var(--md-shape-corner-extra-large);
      text-align: center;
      animation: banner-enter var(--md-motion-duration-short) ease;
    }
    .loading-spinner {
      width: 40px; height: 40px;
      border: 3.5px solid rgba(168,199,250,.2);
      border-top-color: var(--md-sys-color-primary);
      border-radius: 50%;
      animation: spin .8s linear infinite;
    }
    .loading-title {
      font-size: 1rem; font-weight: 600; color: var(--md-sys-color-on-surface);
    }
    .loading-desc {
      font-size: .82rem; color: var(--md-sys-color-on-surface-variant);
    }

    .btn-tonal-appbar {
      display: inline-flex; align-items: center; gap: 7px;
      height: 40px; padding: 0 16px; flex-shrink: 0;
      border-radius: var(--md-shape-corner-full);
      border: 1.5px solid var(--md-sys-color-outline);
      background: var(--md-sys-color-surface-container);
      color: var(--md-sys-color-on-surface);
      font-family: inherit; font-size: .84rem; font-weight: 500;
      cursor: pointer; position: relative;
      transition: background var(--md-motion-duration-short), border-color var(--md-motion-duration-short), color var(--md-motion-duration-short);
    }
    .btn-tonal-appbar:hover { background: var(--md-sys-color-surface-container-high); border-color: var(--md-sys-color-primary); }
    .btn-tonal-appbar.active { background: rgba(168,199,250,.18); border-color: var(--md-sys-color-primary); color: var(--md-sys-color-primary); }
    [data-theme="light"] .btn-tonal-appbar:hover { background: rgba(0,0,0,.05); }

    .queue-live-dot {
      width: 8px; height: 8px; border-radius: 50%;
      background: var(--md-sys-color-secondary);
      box-shadow: 0 0 0 3px rgba(127,207,189,.35);
      animation: pulse-ring 1.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
    }

    .scrape-queue-popover {
      position: fixed; top: 68px; right: 24px; z-index: 1050;
      width: 460px; max-width: calc(100vw - 32px); max-height: calc(100vh - 84px);
      background: var(--md-sys-color-surface);
      border: 1px solid var(--md-sys-color-outline-variant);
      border-radius: var(--md-shape-corner-extra-large);
      box-shadow: var(--md-elevation-3);
      display: flex; flex-direction: column; overflow: hidden;
      animation: dialog-enter var(--md-motion-duration-short) var(--md-motion-emphasized);
    }
    [data-theme="light"] .scrape-queue-popover { background: var(--md-sys-color-surface); }

    .queue-header {
      padding: 14px 18px;
      border-bottom: 1px solid var(--md-sys-color-outline-variant);
      display: flex; align-items: center; justify-content: space-between;
      background: var(--md-sys-color-surface-container-high);
    }
    .queue-title-wrap { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .95rem; color: var(--md-sys-color-on-surface); }
    .queue-close-btn {
      width: 28px; height: 28px; border-radius: 50%;
      border: none; background: transparent; color: var(--md-sys-color-on-surface-variant);
      font-size: 1.2rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
      transition: background var(--md-motion-duration-short);
    }
    .queue-close-btn:hover { background: rgba(255,255,255,.08); color: var(--md-sys-color-on-surface); }
    .queue-body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
    .queue-section-title { font-size: .72rem; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--md-sys-color-on-surface-variant); margin-bottom: 2px; }
    
    .queue-live-card {
      background: var(--md-sys-color-surface-container-low);
      border: 1px solid var(--md-sys-color-outline-variant);
      border-radius: var(--md-shape-corner-large);
      padding: 14px 16px; display: flex; flex-direction: column; gap: 8px;
    }
    .queue-idle-text { font-size: .84rem; color: var(--md-sys-color-on-surface-variant); display: flex; align-items: center; gap: 6px; }

    .queue-history-list { display: flex; flex-direction: column; gap: 8px; max-height: 380px; overflow-y: auto; }
    .queue-item-card {
      background: var(--md-sys-color-surface-container-low);
      border: 1px solid var(--md-sys-color-outline-variant);
      border-radius: var(--md-shape-corner-medium);
      padding: 11px 13px; display: flex; flex-direction: column; gap: 5px;
      transition: background var(--md-motion-duration-short);
    }
    .queue-item-card:hover { background: var(--md-sys-color-surface-container); }
    .queue-item-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .84rem; font-weight: 600; }
    .queue-item-meta { display: flex; align-items: center; justify-content: space-between; font-size: .78rem; color: var(--md-sys-color-on-surface-variant); }
    .queue-badge-status {
      display: inline-flex; align-items: center; gap: 4px;
      padding: 2px 8px; border-radius: var(--md-shape-corner-full);
      font-size: .7rem; font-weight: 700;
    }
    .q-completed   { background: rgba(0,80,74,.4); color: var(--md-sys-color-secondary); border: 1px solid rgba(127,207,189,.35); }
    .q-running     { background: rgba(8,66,160,.4); color: var(--md-sys-color-primary); border: 1px solid rgba(168,199,250,.4); }
    .q-interrupted { background: rgba(100,60,0,.35); color: #fbc02d; border: 1px solid rgba(251,192,45,.4); }
    .q-failed      { background: rgba(104,0,3,.4); color: var(--md-sys-color-error); border: 1px solid rgba(255,179,174,.35); }

    ::-webkit-scrollbar { width: 6px; height: 6px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb { background: var(--md-sys-color-outline); border-radius: 3px; }
    ::-webkit-scrollbar-thumb:hover { background: var(--md-sys-color-on-surface-variant); }

    /* ─── Smart Cart Button (Top Bar) ────────────────────────── */
    .cart-btn {
      display: inline-flex; align-items: center; gap: 8px;
      height: 40px; padding: 0 16px; flex-shrink: 0;
      border-radius: var(--md-shape-corner-full);
      border: 1.5px solid var(--md-sys-color-outline);
      background: var(--md-sys-color-surface-container);
      color: var(--md-sys-color-on-surface);
      font-family: inherit; font-size: .84rem; font-weight: 500;
      cursor: pointer; position: relative;
      transition: background var(--md-motion-duration-short),
                  border-color var(--md-motion-duration-short),
                  color var(--md-motion-duration-short);
    }
    .cart-btn:hover { background: var(--md-sys-color-surface-container-high); border-color: var(--md-sys-color-secondary); color: var(--md-sys-color-secondary); }
    .cart-btn.has-items { border-color: var(--md-sys-color-secondary); color: var(--md-sys-color-secondary); background: rgba(127,207,189,.12); }
    .cart-count-badge {
      display: none;
      min-width: 19px; height: 19px;
      border-radius: 10px; padding: 0 5px;
      background: var(--md-sys-color-secondary);
      color: #003d35; font-size: .7rem; font-weight: 800;
      align-items: center; justify-content: center;
    }
    .cart-btn.has-items .cart-count-badge { display: inline-flex; }
    .cart-total-label { font-size: .8rem; font-weight: 700; }

    /* ─── Add to cart button on cards ────────────────────────── */
    .btn-cart-add {
      flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
      height: 40px; padding: 0 16px;
      border-radius: var(--md-shape-corner-large);
      border: 1.5px solid var(--md-sys-color-secondary);
      background: rgba(127,207,189,.10); color: var(--md-sys-color-secondary);
      font-family: inherit; font-size: .85rem; font-weight: 600;
      cursor: pointer; transition: background var(--md-motion-duration-short), border-color var(--md-motion-duration-short);
    }
    .btn-cart-add:hover { background: rgba(127,207,189,.22); }
    .btn-cart-add.in-cart { background: rgba(127,207,189,.22); }

    .cart-stepper {
      flex: 1; display: flex; align-items: center; justify-content: space-between;
      height: 40px; border-radius: var(--md-shape-corner-large);
      border: 1.5px solid var(--md-sys-color-secondary);
      background: rgba(127,207,189,.12); overflow: hidden;
    }
    .cart-stepper-btn {
      width: 40px; height: 100%;
      border: none; background: transparent; cursor: pointer;
      color: var(--md-sys-color-secondary); font-size: 1.2rem; font-weight: 700;
      display: flex; align-items: center; justify-content: center;
      transition: background var(--md-motion-duration-short);
    }
    .cart-stepper-btn:hover { background: rgba(127,207,189,.2); }
    .cart-stepper-qty {
      flex: 1; text-align: center;
      font-weight: 700; font-size: .95rem; color: var(--md-sys-color-secondary);
    }

    /* ─── Smart Cart Drawer ───────────────────────────────────── */
    .cart-backdrop {
      display: none; position: fixed; inset: 0;
      background: rgba(0,0,0,.55);
      backdrop-filter: blur(6px);
      -webkit-backdrop-filter: blur(6px);
      z-index: 1060;
    }
    .cart-backdrop.open { display: block; }

    .cart-drawer {
      position: fixed; top: 0; right: 0; bottom: 0;
      width: 460px; max-width: 100vw;
      background: var(--md-sys-color-surface);
      border-left: 1px solid var(--md-sys-color-outline-variant);
      z-index: 1061; display: flex; flex-direction: column;
      box-shadow: -8px 0 40px rgba(0,0,0,.45);
      transform: translateX(100%);
      transition: transform var(--md-motion-duration-long) var(--md-motion-emphasized);
    }
    .cart-drawer.open { transform: translateX(0); }
    [data-theme="light"] .cart-drawer { box-shadow: -4px 0 24px rgba(0,0,0,.15); }

    .cart-drawer-header {
      display: flex; align-items: center; justify-content: space-between;
      padding: 18px 20px 14px;
      border-bottom: 1px solid var(--md-sys-color-outline-variant);
      background: var(--md-sys-color-surface-container-high);
      flex-shrink: 0;
    }
    .cart-drawer-title {
      display: flex; align-items: center; gap: 10px;
      font-size: 1.1rem; font-weight: 700; color: var(--md-sys-color-on-surface);
    }
    .cart-drawer-close {
      width: 36px; height: 36px; border-radius: 50%;
      border: 1px solid var(--md-sys-color-outline);
      background: transparent; color: var(--md-sys-color-on-surface-variant);
      font-size: 1.1rem; cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      transition: background var(--md-motion-duration-short);
    }
    .cart-drawer-close:hover { background: var(--md-sys-color-surface-variant); color: var(--md-sys-color-on-surface); }

    .cart-empty-state {
      flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
      gap: 12px; color: var(--md-sys-color-on-surface-variant); padding: 40px;
      text-align: center;
    }
    .cart-empty-icon { font-size: 3.5rem; opacity: .7; }
    .cart-empty-title { font-size: 1rem; font-weight: 600; color: var(--md-sys-color-on-surface); }
    .cart-empty-desc { font-size: .85rem; line-height: 1.5; }

    .cart-items-list { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }

    .cart-item {
      display: flex; gap: 12px; align-items: flex-start;
      padding: 12px 14px;
      background: var(--md-sys-color-surface-container-low);
      border: 1px solid var(--md-sys-color-outline-variant);
      border-radius: var(--md-shape-corner-large);
      transition: background var(--md-motion-duration-short);
    }
    .cart-item:hover { background: var(--md-sys-color-surface-container); }
    .cart-item-img {
      width: 56px; height: 56px; flex-shrink: 0;
      background: white; border-radius: var(--md-shape-corner-medium);
      object-fit: contain; padding: 4px; cursor: pointer;
    }
    .cart-item-body { flex: 1; min-width: 0; }
    .cart-item-brand { font-size: .68rem; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--md-sys-color-tertiary); }
    .cart-item-name {
      font-size: .875rem; font-weight: 500; color: var(--md-sys-color-on-surface);
      text-decoration: none; line-height: 1.35;
      display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
      cursor: pointer;
    }
    .cart-item-name:hover { color: var(--md-sys-color-primary); }
    .cart-item-prices {
      display: flex; align-items: baseline; gap: 6px; margin-top: 4px; flex-wrap: wrap;
    }
    .cart-item-final { font-size: 1rem; font-weight: 700; color: var(--md-sys-color-secondary); }
    .cart-item-list { font-size: .8rem; color: var(--md-sys-color-on-surface-variant); text-decoration: line-through; }
    .cart-item-saving { font-size: .72rem; font-weight: 700; color: #22c55e; background: rgba(34,197,94,.12); padding: 1px 7px; border-radius: 8px; }
    .cart-item-unit { font-size: .72rem; font-weight: 600; color: var(--md-sys-color-primary); background: rgba(168,199,250,.12); padding: 1px 7px; border-radius: 8px; }

    .cart-item-controls {
      display: flex; align-items: center; justify-content: space-between; margin-top: 8px;
    }
    .cart-item-stepper {
      display: flex; align-items: center; gap: 0;
      border: 1.5px solid var(--md-sys-color-secondary);
      border-radius: 10px; overflow: hidden; height: 32px;
      background: rgba(127,207,189,.08);
    }
    .cart-item-stepper-btn {
      width: 32px; height: 100%; border: none; background: transparent;
      cursor: pointer; color: var(--md-sys-color-secondary); font-size: 1.05rem; font-weight: 700;
      display: flex; align-items: center; justify-content: center;
      transition: background var(--md-motion-duration-short);
    }
    .cart-item-stepper-btn:hover { background: rgba(127,207,189,.2); }
    .cart-item-stepper-qty {
      min-width: 28px; text-align: center;
      font-size: .9rem; font-weight: 700; color: var(--md-sys-color-secondary);
    }
    .cart-item-subtotal {
      font-size: .9rem; font-weight: 700; color: var(--md-sys-color-on-surface);
    }
    .cart-item-remove {
      background: transparent; border: none; cursor: pointer;
      color: var(--md-sys-color-on-surface-variant); opacity: .6;
      font-size: .8rem; padding: 4px 6px; border-radius: 6px;
      transition: opacity var(--md-motion-duration-short), color var(--md-motion-duration-short), background var(--md-motion-duration-short);
    }
    .cart-item-remove:hover { opacity: 1; color: var(--md-sys-color-error); background: rgba(255,179,174,.12); }
    .cart-item-open-btn {
      display: inline-flex; align-items: center; gap: 4px;
      font-size: .75rem; font-weight: 600;
      color: var(--md-sys-color-primary); background: rgba(168,199,250,.10);
      border: 1px solid var(--md-sys-color-outline);
      border-radius: 8px; padding: 3px 9px; cursor: pointer; text-decoration: none;
      transition: background var(--md-motion-duration-short);
    }
    .cart-item-open-btn:hover { background: rgba(168,199,250,.22); }

    /* ─── Cart Summary Footer ─────────────────────────────────── */
    .cart-footer {
      flex-shrink: 0; border-top: 1px solid var(--md-sys-color-outline-variant);
      background: var(--md-sys-color-surface-container);
      padding: 16px 20px; display: flex; flex-direction: column; gap: 12px;
    }
    .cart-summary-grid {
      display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    }
    .cart-summary-cell {
      background: var(--md-sys-color-surface-container-low);
      border: 1px solid var(--md-sys-color-outline-variant);
      border-radius: var(--md-shape-corner-large);
      padding: 10px 14px;
    }
    .cart-summary-label { font-size: .68rem; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--md-sys-color-on-surface-variant); margin-bottom: 3px; }
    .cart-summary-value { font-family: 'Google Sans Display', sans-serif; font-size: 1.25rem; font-weight: 700; letter-spacing: -.3px; }
    .cart-saving-cell {
      grid-column: 1 / -1;
      background: rgba(34,197,94,.1);
      border-color: rgba(34,197,94,.3);
      display: flex; align-items: center; justify-content: space-between;
    }
    .cart-saving-amount { font-size: 1.3rem; font-weight: 800; color: #22c55e; letter-spacing: -.3px; }
    .cart-saving-pct { font-size: .75rem; font-weight: 700; color: #22c55e; background: rgba(34,197,94,.15); padding: 2px 8px; border-radius: 8px; }

    .cart-actions { display: flex; flex-direction: column; gap: 8px; }
    .btn-cart-open-all {
      display: flex; align-items: center; justify-content: center; gap: 8px;
      height: 44px; border-radius: var(--md-shape-corner-large);
      background: var(--md-sys-color-secondary); color: #003d35;
      border: none; font-family: inherit; font-size: .9rem; font-weight: 700;
      cursor: pointer; transition: opacity var(--md-motion-duration-short), transform var(--md-motion-duration-short);
    }
    .btn-cart-open-all:hover { opacity: .88; transform: translateY(-1px); }
    .cart-secondary-actions { display: flex; gap: 8px; }
    .btn-cart-copy, .btn-cart-clear {
      flex: 1; height: 38px; border-radius: var(--md-shape-corner-large);
      border: 1.5px solid var(--md-sys-color-outline);
      background: transparent; font-family: inherit; font-size: .82rem; font-weight: 600;
      cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
      transition: background var(--md-motion-duration-short), color var(--md-motion-duration-short);
    }
    .btn-cart-copy { color: var(--md-sys-color-primary); }
    .btn-cart-copy:hover { background: rgba(168,199,250,.14); border-color: var(--md-sys-color-primary); }
    .btn-cart-clear { color: var(--md-sys-color-error); border-color: rgba(255,179,174,.4); }
    .btn-cart-clear:hover { background: rgba(255,179,174,.12); border-color: var(--md-sys-color-error); }

    @keyframes cart-item-enter {
      from { opacity: 0; transform: translateX(12px); }
      to   { opacity: 1; transform: translateX(0); }
    }
    .cart-item { animation: cart-item-enter var(--md-motion-duration-short) var(--md-motion-emphasized); }


    /* === Wizard & Storico Spese === */
    .wizard-btn {
      display: inline-flex; align-items: center; gap: 8px;
      height: 40px; padding: 0 16px; flex-shrink: 0;
      border-radius: var(--md-shape-corner-full);
      border: 1.5px solid var(--md-sys-color-tertiary);
      background: rgba(168,199,250,.08); color: var(--md-sys-color-tertiary);
      font-family: inherit; font-size: .84rem; font-weight: 600; cursor: pointer;
      transition: background var(--md-motion-duration-short), border-color var(--md-motion-duration-short);
    }
    .wizard-btn:hover { background: rgba(168,199,250,.18); }
    .wizard-btn.has-data { border-color: var(--md-sys-color-primary); color: var(--md-sys-color-primary); background: rgba(168,199,250,.12); }
    .full-modal { display: none; position: fixed; inset: 0; z-index: 1070; background: rgba(0,0,0,.7); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); align-items: flex-start; justify-content: center; padding: 20px; overflow-y: auto; }
    .full-modal.open { display: flex; }
    /* BUG: senza max-height la card cresceva quanto il contenuto, quindi
       `.full-modal-body` (overflow-y:auto) era alto esattamente come il suo
       contenuto e NON aveva nulla da scrollare: lo scroll restava sul backdrop
       `.full-modal`, che la rotella non raggiungeva -> lista del wizard bloccata.
       max-height + min-height:0 rendono il body davvero scrollabile.
       Vedi [WIZARD-GOTCHA] in MEMORY.md. */
    .full-modal-card { width: 100%; max-width: 900px; background: var(--md-sys-color-surface); border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--md-shape-corner-extra-large); box-shadow: 0 24px 80px rgba(0,0,0,.5); display: flex; flex-direction: column; overflow: hidden; min-height: 0; max-height: calc(100vh - 40px); }
    .full-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 16px; background: var(--md-sys-color-surface-container-high); border-bottom: 1px solid var(--md-sys-color-outline-variant); flex-shrink: 0; }
    .full-modal-title { font-size: 1.15rem; font-weight: 700; color: var(--md-sys-color-on-surface); display: flex; align-items: center; gap: 10px; }
    .full-modal-close { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--md-sys-color-outline); background: transparent; color: var(--md-sys-color-on-surface-variant); font-size: 1.1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background var(--md-motion-duration-short); }
    .full-modal-close:hover { background: var(--md-sys-color-surface-container-highest); color: var(--md-sys-color-on-surface); }
    .full-modal-body { flex: 1; padding: 24px; overflow-y: auto; }
    .modal-tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--md-sys-color-outline-variant); }
    .modal-tab { padding: 10px 18px; font-size: .88rem; font-weight: 600; cursor: pointer; border: none; background: transparent; color: var(--md-sys-color-on-surface-variant); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color var(--md-motion-duration-short), border-color var(--md-motion-duration-short); }
    .modal-tab:hover { color: var(--md-sys-color-on-surface); }
    .modal-tab.active { color: var(--md-sys-color-primary); border-bottom-color: var(--md-sys-color-primary); }
    .modal-tab-panel { display: none; }
    .modal-tab-panel.active { display: block; }
    .stats-kpi-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 20px; }
    .stats-kpi { background: var(--md-sys-color-surface-container-low); border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--md-shape-corner-large); padding: 14px 18px; }
    .stats-kpi-label { font-size: .68rem; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--md-sys-color-on-surface-variant); margin-bottom: 4px; }
    .stats-kpi-value { font-size: 1.6rem; font-weight: 800; letter-spacing: -.5px; color: var(--md-sys-color-secondary); }
    .stats-section-title { font-size: .78rem; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--md-sys-color-on-surface-variant); margin: 18px 0 10px; }
    .stats-bar-list { display: flex; flex-direction: column; gap: 8px; }
    .stats-bar-item { display: flex; align-items: center; gap: 10px; }
    .stats-bar-label { font-size: .85rem; font-weight: 500; color: var(--md-sys-color-on-surface); min-width: 160px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .stats-bar-track { flex: 1; height: 8px; background: var(--md-sys-color-surface-container-high); border-radius: 4px; overflow: hidden; }
    .stats-bar-fill { height: 100%; border-radius: 4px; background: var(--md-sys-color-secondary); transition: width .5s var(--md-motion-emphasized); }
    .stats-bar-count { font-size: .78rem; font-weight: 700; color: var(--md-sys-color-secondary); min-width: 30px; text-align: right; }
    .import-drop-zone { border: 2px dashed var(--md-sys-color-outline); border-radius: var(--md-shape-corner-extra-large); padding: 48px 24px; text-align: center; cursor: pointer; transition: border-color var(--md-motion-duration-short), background var(--md-motion-duration-short); }
    .import-drop-zone:hover, .import-drop-zone.drag-over { border-color: var(--md-sys-color-primary); background: rgba(168,199,250,.06); }
    .import-drop-icon { font-size: 3rem; margin-bottom: 12px; opacity: .7; }
    .import-drop-title { font-size: 1rem; font-weight: 600; color: var(--md-sys-color-on-surface); margin-bottom: 6px; }
    .import-drop-desc { font-size: .83rem; color: var(--md-sys-color-on-surface-variant); line-height: 1.5; }
    .import-progress { display: none; margin-top: 16px; background: var(--md-sys-color-surface-container-low); border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--md-shape-corner-large); padding: 16px 20px; }
    .import-progress.visible { display: block; }
    .import-history-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
    .import-history-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-radius: var(--md-shape-corner-large); background: var(--md-sys-color-surface-container-low); border: 1px solid var(--md-sys-color-outline-variant); font-size: .83rem; }
    .btn-import-delete { background: transparent; border: 1px solid var(--md-sys-color-outline-variant); cursor: pointer; color: var(--md-sys-color-error); padding: 6px 12px; border-radius: 8px; font-family: inherit; font-size: .78rem; font-weight: 600; opacity: .8; white-space: nowrap; transition: opacity var(--md-motion-duration-short), background var(--md-motion-duration-short), border-color var(--md-motion-duration-short); }
    .btn-import-delete:hover { opacity: 1; background: rgba(255,179,174,.12); border-color: var(--md-sys-color-error); }
    .wizard-steps { display: flex; gap: 0; margin-bottom: 24px; }
    .wizard-step { flex: 1; text-align: center; padding: 10px 0; font-size: .78rem; font-weight: 600; color: var(--md-sys-color-on-surface-variant); border-bottom: 2px solid var(--md-sys-color-outline-variant); transition: color var(--md-motion-duration-short), border-color var(--md-motion-duration-short); }
    .wizard-step.active { color: var(--md-sys-color-primary); border-bottom-color: var(--md-sys-color-primary); }
    .wizard-step.done { color: var(--md-sys-color-secondary); border-bottom-color: var(--md-sys-color-secondary); }
    .wizard-step-panel { display: none; }
    .wizard-step-panel.active { display: block; }
    .cat-chip-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
    .cat-chip { display: flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: var(--md-shape-corner-full); border: 1.5px solid var(--md-sys-color-outline); background: var(--md-sys-color-surface-container); font-size: .83rem; font-weight: 500; cursor: pointer; color: var(--md-sys-color-on-surface); transition: background var(--md-motion-duration-short), border-color var(--md-motion-duration-short); }
    .cat-chip:hover { background: var(--md-sys-color-surface-container-high); }
    .cat-chip.selected { background: rgba(168,199,250,.18); border-color: var(--md-sys-color-primary); color: var(--md-sys-color-primary); font-weight: 700; }
    .cat-chip-count { font-size: .72rem; font-weight: 700; background: var(--md-sys-color-secondary); color: #003d35; border-radius: 8px; padding: 1px 7px; }
    .wizard-results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-top: 16px; }
    .wizard-product-card { background: var(--md-sys-color-surface-container-low); border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--md-shape-corner-large); overflow: hidden; display: flex; flex-direction: column; transition: background var(--md-motion-duration-short); }
    .wizard-product-card:hover { background: var(--md-sys-color-surface-container); }
    .wizard-product-img { width: 100%; height: 100px; object-fit: contain; background: white; padding: 8px; }
    .wizard-product-body { padding: 10px 12px; flex: 1; display: flex; flex-direction: column; gap: 3px; }
    .wizard-product-brand { font-size: .65rem; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--md-sys-color-tertiary); }
    .wizard-product-title { font-size: .82rem; font-weight: 500; color: var(--md-sys-color-on-surface); line-height: 1.3; flex: 1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    .wizard-product-price { font-size: 1rem; font-weight: 700; color: var(--md-sys-color-secondary); }
    .wizard-product-score { font-size: .72rem; font-weight: 700; color: #22c55e; }
    .wizard-product-bought { font-size: .72rem; color: var(--md-sys-color-on-surface-variant); }
    .btn-wizard-add { margin: 0 10px 10px; height: 34px; border-radius: var(--md-shape-corner-large); border: 1.5px solid var(--md-sys-color-secondary); background: rgba(127,207,189,.1); color: var(--md-sys-color-secondary); font-family: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; transition: background var(--md-motion-duration-short); }
    .btn-wizard-add:hover { background: rgba(127,207,189,.22); }
    .btn-wizard-add.in-cart { background: rgba(127,207,189,.28); }
    .wizard-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; }
    .btn-wizard-nav { height: 40px; padding: 0 20px; border-radius: var(--md-shape-corner-large); border: 1.5px solid var(--md-sys-color-outline); background: transparent; font-family: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; color: var(--md-sys-color-on-surface); transition: background var(--md-motion-duration-short); }
    .btn-wizard-nav:hover { background: var(--md-sys-color-surface-container-high); }
    .btn-wizard-primary { height: 40px; padding: 0 24px; border-radius: var(--md-shape-corner-large); border: none; background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); font-family: inherit; font-size: .88rem; font-weight: 700; cursor: pointer; transition: opacity var(--md-motion-duration-short); }
    .btn-wizard-primary:hover { opacity: .88; }

/* ═══════════════════════════════════════════════════════════════
   M3 EXPRESSIVE — MICRO-INTERAZIONI & MOBILE LAYOUT
   ═══════════════════════════════════════════════════════════════ */

/* ── Ripple ─────────────────────────────────────────────────── */
.ripple-host { position: relative; overflow: hidden; }
.ripple-wave {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,.28);
  transform: scale(0);
  animation: ripple-expand 480ms cubic-bezier(.2,0,.2,1) forwards;
  pointer-events: none;
  z-index: 9;
}
@keyframes ripple-expand {
  to { transform: scale(4); opacity: 0; }
}

/* ── Press Bounce ───────────────────────────────────────────── */
/* NB: qui NON va .cat-tree-node: è il contenitore dell'intero sottoalbero,
   quindi il bounce (e ancor peggio il ripple con overflow:hidden) fa
   collassare/spostare tutte le righe sotto il dito. Il target è .cat-btn. */
.btn-primary:active,
.btn-tonal:active,
.btn-tonal-appbar:active,
.btn-icon:active,
.filter-chip:active,
.cat-btn:active,
.m3-nav-item:active,
.btn-wizard-add:active,
.btn-wizard-nav:active,
.btn-wizard-primary:active,
.wizard-product-card:active { transform: scale(.96); transition: transform 100ms cubic-bezier(.2,0,0,1.4) !important; }
.prod-card:active { transform: scale(.97); transition: transform 100ms cubic-bezier(.2,0,0,1.4) !important; }

/* ── Bottom Navigation Bar (Default Desktop: Nascosta) ─────────── */
.m3-bottom-nav {
  display: none;
}

/* ── Elementi Mobile-Only (Default Desktop: Nascosti) ───────────── */
.sidebar-drag-handle,
.sidebar-header-mobile,
.sheet-close-btn,
.m3-hamburger-btn,
.sheet-scrim {
  display: none;
}

/* ── Top App Bar Scroll Elevation (Desktop + Mobile) ───────────── */
.top-app-bar {
  transition: box-shadow 200ms var(--md-motion-standard),
              background 200ms var(--md-motion-standard);
}
.top-app-bar.scrolled {
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
  background: var(--md-sys-color-surface-container-high);
}

/* ═══════════════════════════════════════════════════════════════
   MATERIAL 3 EXPRESSIVE — MOBILE BREAKPOINT (<= 840px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 840px) {

  /* 1. Global Touch Reset & Overflow Protection */
  html, body {
    /* `clip`, NON `hidden`: overflow-x:hidden trasforma body in un contenitore
       di scroll che pero' non scorre (scorre la finestra), e la top bar
       `position: sticky` si aggancia a lui -> spariva appena si scorreva
       (misurato: top -1500 px dopo 1500 px di scroll). `clip` taglia
       l'overflow orizzontale senza creare un contenitore di scroll. */
    overflow-x: clip !important;
    width: 100% !important;
    max-width: 100vw !important;
    -webkit-text-size-adjust: 100%;
  }

  *, *::before, *::after {
    box-sizing: border-box;
  }

  /* 2. Top App Bar Compatta */
  .top-app-bar {
    /* La safe-area va sommata ANCHE qui: senza, questo `height`/`padding`
       con !important cancellerebbe il padding-top del notch proprio su mobile,
       cioe' l'unico posto dove serve. */
    height: calc(56px + env(safe-area-inset-top, 0px)) !important;
    padding: calc(env(safe-area-inset-top, 0px)) 8px 0 12px !important;
    gap: 8px !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 850 !important;
  }
  .app-bar-logo {
    width: 30px !important;
    height: 30px !important;
  }
  .app-bar-logo svg {
    width: 16px !important;
    height: 16px !important;
  }
  .app-bar-title {
    font-size: 0.95rem !important;
    flex: 1 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Nascondi bottoni desktop ridondanti (gestiti dalla Bottom Nav) */
  .theme-seg,
  .wizard-btn,
  .cart-btn,
  .btn-tonal-appbar,
  .btn-scrape,
  .app-bar-pill,
  .desktop-only {
    display: none !important;
  }

  /* Hamburger Menu Reparti */
  .m3-hamburger-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    border: none !important;
    background: transparent !important;
    color: var(--md-sys-color-on-surface) !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    -webkit-tap-highlight-color: transparent;
  }
  .m3-hamburger-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
  }
  .m3-hamburger-btn:active {
    background: rgba(168, 199, 250, 0.15) !important;
  }

  /* 3. Layout Principale: Colonna Fluida */
  .page-layout, .page {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 10px 10px 84px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
  }

  .page-main {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* 4. Statistiche: Griglia 2x2 Compatta Touch-first */
  .stats-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    margin-bottom: 12px !important;
    width: 100% !important;
  }
  .stat-card {
    padding: 10px 12px !important;
    border-radius: 16px !important;
    gap: 4px !important;
  }
  .stat-icon {
    width: 28px !important;
    height: 28px !important;
    font-size: 0.85rem !important;
    border-radius: 8px !important;
  }
  .stat-label {
    font-size: 0.70rem !important;
    letter-spacing: 0.2px !important;
  }
  .stat-value {
    font-size: 1.35rem !important;
    letter-spacing: -0.5px !important;
  }

  /* 5. Pannello Ricerca e Filtri */
  .search-panel {
    padding: 10px !important;
    margin-bottom: 12px !important;
    border-radius: 18px !important;
    gap: 8px !important;
    width: 100% !important;
  }
  .search-field {
    height: 44px !important;
    padding: 0 14px !important;
    border-radius: 22px !important;
    width: 100% !important;
  }
  .search-input {
    font-size: 0.9rem !important;
  }

  /* Carousel orizzontale filtri con scroll fluido */
  .controls-row {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    gap: 6px !important;
    padding: 2px 0 4px !important;
    width: 100% !important;
  }
  .controls-row::-webkit-scrollbar {
    display: none !important;
  }
  .filter-chip {
    height: 32px !important;
    min-height: 32px !important;
    font-size: 0.78rem !important;
    padding: 0 12px !important;
    flex-shrink: 0 !important;
    border-radius: 16px !important;
  }
  .m3-select {
    height: 34px !important;
    font-size: 0.78rem !important;
    padding: 4px 28px 4px 10px !important;
    flex-shrink: 0 !important;
    max-width: 150px !important;
  }
  .segmented-btn {
    flex-shrink: 0 !important;
    margin-left: 0 !important;
    height: 32px !important;
  }
  .seg-option {
    height: 32px !important;
    padding: 0 12px !important;
    font-size: 0.75rem !important;
  }

  /* 6. Griglia Prodotti: 2 Colonne Solide */
  .product-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
    margin: 0 !important;
  }
  .prod-card {
    min-width: 0 !important;
    width: 100% !important;
    border-radius: 16px !important;
    contain-intrinsic-size: auto 260px !important;
  }
  .prod-img-wrap {
    height: 105px !important;
    padding: 6px !important;
  }
  .prod-img-wrap a {
    padding: 4px !important;
  }
  .badge-overlay {
    top: 6px !important;
    right: 6px !important;
  }
  .m3-badge {
    font-size: 0.62rem !important;
    padding: 2px 6px !important;
  }
  .prod-body {
    padding: 8px !important;
    gap: 3px !important;
  }
  .prod-brand {
    font-size: 0.62rem !important;
    letter-spacing: 0.5px !important;
  }
  .prod-title {
    font-size: 0.76rem !important;
    line-height: 1.25 !important;
    height: 2.5em !important;
    -webkit-line-clamp: 2 !important;
  }
  .price-area {
    gap: 4px !important;
    margin-top: 2px !important;
  }
  .price-final {
    font-size: 1.05rem !important;
    letter-spacing: -0.4px !important;
  }
  .price-list {
    font-size: 0.75rem !important;
  }
  .price-unit {
    font-size: 0.65rem !important;
    padding: 1px 6px !important;
  }
  .price-meta {
    font-size: 0.66rem !important;
    line-height: 1.3 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 1 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
  }
  .prod-actions {
    padding: 0 8px 8px !important;
    gap: 4px !important;
  }
  .prod-actions .btn-tonal {
    height: 32px !important;
    font-size: 0.72rem !important;
    padding: 0 6px !important;
    border-radius: 8px !important;
    flex: 1 !important;
  }
  .prod-actions .btn-cart-add {
    height: 32px !important;
    font-size: 0.72rem !important;
    padding: 0 6px !important;
    border-radius: 8px !important;
    flex: 1 !important;
    gap: 3px !important;
  }
  .prod-actions .btn-cart-add svg {
    width: 12px !important;
    height: 12px !important;
  }
  .prod-actions .cart-stepper {
    height: 32px !important;
    border-radius: 8px !important;
  }
  .prod-actions .cart-stepper-btn {
    width: 28px !important;
    font-size: 0.95rem !important;
  }
  .prod-actions .cart-stepper-qty {
    font-size: 0.8rem !important;
  }

  /* 7. Bottom Navigation Bar M3 Expressive (Fissa in Basso) */
  .m3-bottom-nav {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 64px !important;
    background: var(--md-sys-color-surface-container) !important;
    border-top: 1px solid var(--md-sys-color-outline-variant) !important;
    z-index: 900 !important;
    align-items: center !important;
    justify-content: space-around !important;
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    box-shadow: 0 -2px 10px rgba(0,0,0,.15) !important;
  }
  .m3-nav-item {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 2px !important;
    cursor: pointer !important;
    padding: 6px 0 !important;
    border: none !important;
    background: transparent !important;
    color: var(--md-sys-color-on-surface-variant) !important;
    font-family: inherit !important;
    position: relative !important;
    -webkit-tap-highlight-color: transparent !important;
  }
  .m3-nav-pill {
    position: absolute !important;
    top: 4px !important;
    width: 24px !important;
    height: 28px !important;
    border-radius: 14px !important;
    background: transparent !important;
    transition: width 250ms cubic-bezier(.05,.7,.1,1), background 200ms ease !important;
  }
  .m3-nav-item.active .m3-nav-pill {
    width: 56px !important;
    background: var(--md-sys-color-secondary-container) !important;
  }
  .m3-nav-icon {
    font-size: 22px !important;
    position: relative !important;
    z-index: 1 !important;
  }
  .m3-nav-item.active .m3-nav-icon {
    color: var(--md-sys-color-on-secondary-container) !important;
  }
  .m3-nav-label {
    font-size: 0.65rem !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    position: relative !important;
    z-index: 1 !important;
  }
  .m3-nav-item.active .m3-nav-label {
    color: var(--md-sys-color-on-secondary-container) !important;
    font-weight: 700 !important;
  }
  .m3-nav-badge {
    position: absolute !important;
    top: 2px !important;
    right: calc(50% - 20px) !important;
    min-width: 16px !important;
    height: 16px !important;
    border-radius: 8px !important;
    background: var(--md-sys-color-error) !important;
    color: var(--md-sys-color-on-error) !important;
    font-size: 0.58rem !important;
    font-weight: 700 !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 3px !important;
    z-index: 2 !important;
  }
  .m3-nav-badge.visible {
    display: flex !important;
  }

  /* 8. Sidebar Categorie come Bottom Sheet Fluido */
  .page-sidebar {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 80vh !important;
    max-height: 80vh !important;
    border-radius: 24px 24px 0 0 !important;
    background: var(--md-sys-color-surface-container-low) !important;
    box-shadow: 0 -6px 30px rgba(0,0,0,.35) !important;
    z-index: 1000 !important;
    transform: translateY(100%) !important;
    transition: transform 350ms cubic-bezier(.1,.9,.2,1) !important;
    overflow-y: auto !important;
    padding: 0 0 40px !important;
    border: none !important;
  }
  .page-sidebar.open {
    transform: translateY(0) !important;
  }
  .sidebar-drag-handle {
    display: flex !important;
    justify-content: center !important;
    padding: 12px 0 6px !important;
    cursor: grab !important;
    /* Il gesto sulla maniglia non deve diventare uno scroll della pagina:
       quando il browser se ne appropria arriva pointercancel e il sheet
       restava traslato con la pagina bloccata dietro. */
    touch-action: none !important;
  }
  .sidebar-drag-handle-pill {
    width: 40px !important;
    height: 4px !important;
    border-radius: 2px !important;
    background: var(--md-sys-color-outline) !important;
  }
  .sidebar-header-mobile {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 4px 16px 10px !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    color: var(--md-sys-color-on-surface) !important;
    border-bottom: 1px solid var(--md-sys-color-outline-variant) !important;
  }
  .sidebar-title-mobile {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }
  .sheet-close-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 16px !important;
    border: none !important;
    background: var(--md-sys-color-surface-container-high) !important;
    color: var(--md-sys-color-on-surface) !important;
    cursor: pointer !important;
    font-size: 1.2rem !important;
  }
  .sheet-scrim {
    display: none;
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0,0,0,0.55) !important;
    z-index: 999 !important;
  }
  .sheet-scrim.open {
    display: block !important;
  }
  .sidebar-card {
    border: none !important;
    background: transparent !important;
    padding: 12px 14px !important;
  }
  .category-list {
    max-height: calc(80vh - 120px) !important;
  }

  /* 9. Modali Touch Bottom Sheet */
  .dialog-overlay {
    padding: 0 !important;
    align-items: flex-end !important;
  }
  .dialog {
    max-width: 100% !important;
    width: 100% !important;
    border-radius: 24px 24px 0 0 !important;
    padding: 20px 16px 32px !important;
    max-height: 88vh !important;
    overflow-y: auto !important;
  }
  .cart-drawer {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 24px 24px 0 0 !important;
  }
  .full-modal {
    padding: 0 !important;
    align-items: flex-end !important;
  }
  .full-modal-card {
    max-width: 100% !important;
    border-radius: 24px 24px 0 0 !important;
    max-height: 92vh !important;
  }

  .load-more-bar { flex-direction: column; gap: 8px; }
  .load-more-bar .btn-tonal { width: 100%; }

  /* 10. Banner Scraping & Toast */
  .scrape-banner {
    padding: 10px 12px !important;
    margin-bottom: 12px !important;
    font-size: 0.8rem !important;
  }
  .results-bar {
    margin-bottom: 10px !important;
  }
}

/* ─── Installa app: bottone nell'header (prima FAB fisso) ─────────
   Il FAB in basso a destra copriva il tasto "Carrello" delle card su
   mobile: un'azione occasionale non deve stare sopra il contenuto. */
.pwa-install-btn {
  display: none;
  align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 14px; flex-shrink: 0;
  border: 1.5px solid var(--md-sys-color-outline);
  border-radius: var(--md-shape-corner-full);
  background: transparent;
  color: var(--md-sys-color-primary);
  font-family: inherit; font-size: .85rem; font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--md-motion-duration-short) var(--md-motion-standard);
}
.pwa-install-btn.show { display: inline-flex; }
.pwa-install-btn:hover { background: rgba(168,199,250,.10); }
.pwa-install-btn svg { width: 18px; height: 18px; flex: none; }

@media (max-width: 840px) {
  .pwa-install-btn { width: 40px; padding: 0; border: none; }
  .pwa-install-btn .pwa-install-label { display: none; }
  .pwa-install-btn svg { width: 22px; height: 22px; }
}

/* ─── PWA install sheet (stato installabilità + istruzioni) ──────── */
.pwa-sheet-scrim {
  position: fixed;
  inset: 0;
  z-index: 1290;
  background: rgba(0, 0, 0, .55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--md-motion-duration-medium) var(--md-motion-standard);
}
.pwa-sheet-scrim.open { opacity: 1; pointer-events: auto; }

.pwa-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 1300;
  width: min(560px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  border-radius: 28px 28px 0 0;
  box-shadow: var(--md-elevation-3);
  transform: translate(-50%, 100%);
  transition: transform var(--md-motion-duration-long) var(--md-motion-emphasized);
}
.pwa-sheet.open { transform: translate(-50%, 0); }

.pwa-sheet-handle {
  width: 40px;
  height: 4px;
  margin: 6px auto 16px;
  border-radius: var(--md-shape-corner-full);
  background: var(--md-sys-color-outline);
  opacity: .6;
}
.pwa-sheet-title {
  margin: 0 0 10px;
  font-size: 1.05rem;
  font-weight: 600;
}
.pwa-sheet-verdict {
  margin: 0 0 14px;
  padding: 11px 13px;
  border-radius: var(--md-shape-corner-medium);
  background: var(--md-sys-color-surface-container);
  border-left: 3px solid var(--md-sys-color-outline);
  font-size: .84rem;
  line-height: 1.5;
}
.pwa-sheet-verdict.pwa-ok   { border-left-color: var(--md-sys-color-secondary); }
.pwa-sheet-verdict.pwa-warn { border-left-color: var(--md-sys-color-tertiary); }
.pwa-sheet-verdict.pwa-err  { border-left-color: var(--md-sys-color-error); }

.pwa-diag { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.pwa-diag-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 11px;
  border-radius: var(--md-shape-corner-small);
  background: var(--md-sys-color-surface-container);
  font-size: .79rem;
}
.pwa-diag-label { color: var(--md-sys-color-on-surface-variant); }
.pwa-diag-value { font-weight: 600; text-align: right; }
.pwa-diag-row.pwa-ok   .pwa-diag-value { color: var(--md-sys-color-secondary); }
.pwa-diag-row.pwa-warn .pwa-diag-value { color: var(--md-sys-color-tertiary); }
.pwa-diag-row.pwa-err  .pwa-diag-value { color: var(--md-sys-color-error); }

.pwa-sheet-hints {
  margin-bottom: 16px;
  font-size: .78rem;
  line-height: 1.55;
  color: var(--md-sys-color-on-surface-variant);
}
.pwa-sheet-hints p { margin: 0 0 7px; }

.pwa-sheet-close {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--md-shape-corner-full);
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pwa-sheet-close:active { transform: scale(.98); }

.pwa-sheet-dismiss {
  width: 100%;
  margin-top: 8px;
  padding: 11px;
  border: none;
  border-radius: var(--md-shape-corner-full);
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  font-family: inherit;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pwa-sheet-dismiss:hover { background: var(--md-sys-color-surface-container); }
.pwa-sheet-dismiss:active { transform: scale(.98); }

.pwa-sheet-build {
  margin: 12px 0 0;
  text-align: center;
  font-size: .68rem;
  letter-spacing: .04em;
  color: var(--md-sys-color-on-surface-variant);
  opacity: .75;
}

@media (prefers-reduced-motion: reduce) {
  .pwa-sheet { transition: none; }
}


/* ─── Barra paginazione prodotti ("Carica altri") ───────────────── */
.load-more-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 22px 12px 34px;
}
.load-more-bar .btn-tonal { padding: 12px 22px; font-size: .86rem; }
.load-more-info {
  font-size: .76rem;
  color: var(--md-sys-color-on-surface-variant);
  font-variant-numeric: tabular-nums;
}

/* ── Catalogo: skeleton di caricamento (solo al primissimo accesso) ──
   Stesse dimensioni delle card vere: la griglia non "salta" (CLS) quando
   arrivano i prodotti, e la pagina mostra subito la propria forma. */
.skeleton-card { pointer-events: none; }
.skeleton-card .prod-img-wrap,
.skeleton-card .sk-line {
  background: linear-gradient(90deg,
    var(--md-sys-color-surface-container) 25%,
    var(--md-sys-color-surface-container-high) 50%,
    var(--md-sys-color-surface-container) 75%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.3s ease-in-out infinite;
}
.skeleton-card .prod-body { display: flex; flex-direction: column; gap: 10px; }
.skeleton-card .sk-line { height: 12px; border-radius: 6px; width: 100%; }
.skeleton-card .sk-short { width: 35%; }
.skeleton-card .sk-mid { width: 70%; }
.skeleton-card .sk-price { width: 45%; height: 22px; margin-top: 6px; }
@keyframes sk-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ── Pillola "Prezzi aggiornati" ──
   Compare quando arriva un catalogo nuovo mentre l'utente sta scorrendo:
   niente ridisegno sotto il dito, decide lui quando aggiornare. */
.catalog-update-pill {
  position: fixed; left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 76px);
  transform: translate(-50%, -16px); opacity: 0; pointer-events: none;
  z-index: 950;
  min-height: 40px; padding: 0 18px;
  border: 0; border-radius: var(--md-shape-corner-full, 999px);
  background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary);
  font: 600 .88rem 'Google Sans', 'Roboto', system-ui, sans-serif;
  box-shadow: var(--md-elevation-2);
  cursor: pointer;
  transition: transform .25s ease, opacity .25s ease;
}
.catalog-update-pill.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.catalog-update-pill:focus-visible { outline: 3px solid var(--md-sys-color-on-surface); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .skeleton-card .prod-img-wrap, .skeleton-card .sk-line { animation: none; }
  .catalog-update-pill { transition: none; }
}

/* Icone Material Symbols: se il font non arriva (rete lenta/bloccata) il
   browser mostra il nome della ligatura ("shopping_cart") che sborda e rompe
   la bottom nav. Con larghezza fissa a 1em resta un quadratino vuoto. */
.material-symbols-outlined {
  display: inline-block; width: 1em; overflow: hidden;
  white-space: nowrap; line-height: 1;
}
/* ...e finche' il font non e' pronto il testo della ligatura resta invisibile
   (la classe .icons-ready la mette app.js con document.fonts). */
html:not(.icons-ready) .material-symbols-outlined { color: transparent !important; }

/* ═══════════════════════════════════════════════════════════════
   UI 17/10 (build 20261017-2): contenuto prima, header, storico
   ═══════════════════════════════════════════════════════════════ */

/* Header: "Avvia scraping" e' manutenzione -> stile secondario (contorno),
   non il bottone pieno piu' vistoso della pagina. */
.btn-scrape {
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  border: 1.5px solid var(--md-sys-color-outline);
  font-weight: 500;
}
.btn-scrape:hover:not(:disabled) { background: rgba(168,199,250,.08); color: var(--md-sys-color-on-surface); }
.btn-scrape .spin { border-color: rgba(168,199,250,.3); border-top-color: var(--md-sys-color-primary); }
.btn-scrape.is-running > svg { display: none; }
#scrapeBtnLabel { display: inline-flex; align-items: center; gap: 8px; }
.app-bar-pill.stale { color: var(--md-sys-color-error); border-color: var(--md-sys-color-error); }

/* Cerca (solo mobile) */
.m3-search-btn { display: none; }
@media (max-width: 840px) {
  .m3-search-btn {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
    border: none; background: transparent; cursor: pointer;
    color: var(--md-sys-color-on-surface);
    -webkit-tap-highlight-color: transparent;
  }
  .m3-search-btn svg { width: 22px; height: 22px; }
  .m3-search-btn:active { background: rgba(168,199,250,.15); }

  /* Top bar "enter always" (M3): si nasconde scorrendo verso il basso,
     ricompare appena si risale. Ricerca e reparti sempre a un gesto. */
  .top-app-bar { transition: transform 220ms var(--md-motion-standard), box-shadow 200ms, background 200ms !important; }
  .top-app-bar.app-bar-hidden { transform: translateY(-100%); }
}
@media (prefers-reduced-motion: reduce) {
  .top-app-bar { transition: none !important; }
}

/* Chip filtro con conteggio */
.chip-count {
  display: inline-block; min-width: 0;
  margin-left: 2px; padding: 0 7px;
  border-radius: 999px;
  background: rgba(168,199,250,.14);
  font-size: .75em; font-weight: 700; line-height: 1.6;
  font-variant-numeric: tabular-nums;
}
.chip-count:empty { display: none; }
.filter-chip.active .chip-count { background: rgba(0,0,0,.18); }
[data-theme="light"] .chip-count { background: rgba(8,66,160,.10); }
.controls-divider {
  width: 1px; align-self: stretch; margin: 4px 2px; flex-shrink: 0;
  background: var(--md-sys-color-outline-variant);
}

/* Barra risultati: totale + freschezza dei prezzi */
.results-bar { flex-wrap: wrap; gap: 4px 10px; }
.data-freshness { font-size: .8rem; color: var(--md-sys-color-on-surface-variant); }
.data-freshness:not(:empty)::before { content: '\00b7'; margin-right: 10px; opacity: .6; }
.data-freshness.stale { color: var(--md-sys-color-error); font-weight: 600; }

/* ─── Modale storico prezzi ─────────────────────────────────── */
.price-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px; margin: 14px 0 10px;
}
.ps-tile {
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 14px; padding: 10px 12px; min-width: 0;
}
.ps-label { font-size: .74rem; color: var(--md-sys-color-on-surface-variant); line-height: 1.3; }
.ps-value {
  font-family: 'Google Sans Display', 'Google Sans', sans-serif;
  font-size: 1.35rem; font-weight: 700; line-height: 1.25; margin-top: 2px;
  font-variant-numeric: tabular-nums; color: var(--md-sys-color-on-surface);
}
.ps-note { font-size: .74rem; font-weight: 600; margin-top: 2px; }
.ps-tile.is-today .ps-value, .ps-tile.is-today .ps-note { color: var(--md-sys-color-secondary); }
.ps-tile.is-ref .ps-value { color: var(--md-sys-color-tertiary); }
.ps-tile.is-min .ps-note { color: var(--md-sys-color-secondary); }
.price-explain {
  margin: 0 0 10px; padding: 10px 12px; border-radius: 12px;
  background: rgba(255,179,174,.10); border: 1px solid rgba(255,179,174,.35);
  color: var(--md-sys-color-on-surface); font-size: .85rem; line-height: 1.45;
}
[data-theme="light"] .price-explain { background: var(--md-sys-color-error-container); border-color: rgba(186,26,26,.25); color: var(--md-sys-color-on-error-container); }
.chart-legend {
  display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center;
  margin-top: 8px; font-size: .78rem; color: var(--md-sys-color-on-surface-variant);
}
.chart-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .lg::before { content: ''; width: 18px; height: 0; border-top: 2.5px solid currentColor; }
.chart-legend .lg-paid::before { border-color: var(--md-sys-color-secondary); }
.chart-legend .lg-list::before { border-top: 1.5px dashed var(--md-sys-color-on-surface-variant); }
.chart-legend .lg-ref::before { border-top: 1.5px dotted var(--md-sys-color-tertiary); border-top-width: 2px; }
@media (max-width: 840px) {
  .chart-wrap { height: 240px !important; }
  .ps-value { font-size: 1.15rem; }
}

/* ═══════════════════════════════════════════════════════════════
   MOTION M3 (build 20261017-3) — vedi [MOTION] in MEMORY.md
   Regole: si animano SOLO transform/opacity/scale (compositor, niente
   layout a ogni frame); niente backdrop-filter su mobile; uscite piu'
   brevi delle entrate; tutto si spegne con prefers-reduced-motion.
   ═══════════════════════════════════════════════════════════════ */
:root {
  /* Easing M3 (curve ufficiali) */
  --m3-ease-standard:             cubic-bezier(.2, 0, 0, 1);
  --m3-ease-standard-decelerate:  cubic-bezier(0, 0, 0, 1);
  --m3-ease-standard-accelerate:  cubic-bezier(.3, 0, 1, 1);
  --m3-ease-emph-decelerate:      cubic-bezier(.05, .7, .1, 1);
  --m3-ease-emph-accelerate:      cubic-bezier(.3, 0, .8, .15);
  /* Molle: fallback a curva per i browser senza linear() */
  --m3-spring-spatial:      var(--m3-ease-emph-decelerate);
  --m3-spring-spatial-dur:  400ms;
  --m3-spring-bouncy:       var(--m3-ease-emph-decelerate);
  --m3-spring-bouncy-dur:   350ms;
  --m3-dur-exit:            200ms;
  --m3-dur-fade:            150ms;
  /* il vecchio token "emphasized" aveva un overshoot 1.4 non M3 */
  --md-motion-emphasized:   var(--m3-ease-emph-decelerate);
}
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    /* M3 standard spatial: stiffness 700, damping 0.9 (overshoot 0,1%) */
    --m3-spring-spatial: linear(0, 0.0288, 0.1008, 0.1906, 0.2938, 0.392, 0.4899, 0.5746, 0.6499, 0.7186, 0.7741, 0.8229, 0.8612, 0.8924, 0.9189, 0.9388, 0.9553, 0.9674, 0.9772, 0.9842, 0.9894, 0.9934, 0.9961, 0.9981, 0.9994, 1.0003, 1.0008, 1.0011, 1.0012, 1.0012, 1.0012, 1.0011, 1.001, 1.0008, 1.0007, 1.0006, 1);
    --m3-spring-spatial-dur: 350ms;
    /* M3 Expressive fast spatial: stiffness 800, damping 0.6 (rimbalzo ~9%):
       solo su elementi piccoli (indicatore nav, pressione bottoni, pillole) */
    --m3-spring-bouncy: linear(0, 0.0376, 0.124, 0.2472, 0.3858, 0.526, 0.6514, 0.7689, 0.8681, 0.944, 1.0049, 1.0478, 1.074, 1.0888, 1.0933, 1.0902, 1.0823, 1.071, 1.0581, 1.0456, 1.0332, 1.0221, 1.0132, 1.0056, 0.9998, 0.9957, 0.9932, 0.9918, 0.9913, 0.9915, 0.9923, 0.9933, 0.9945, 0.9957, 0.9968, 0.9979, 0.9987, 0.9994, 1, 1.0004, 1);
    --m3-spring-bouncy-dur: 394ms;
  }
}

html { -webkit-tap-highlight-color: transparent; }
button, a, select, .filter-chip, .m3-nav-item, .cat-btn { touch-action: manipulation; }

/* Ripple = state layer M3: colore del contenuto (currentColor), non bianco
   fisso (sul tema chiaro era invisibile). Parte solo a tocco confermato
   (vedi initRipple): scorrendo la lista non lampeggiano piu' le card. */
.ripple-wave {
  background: currentColor !important;
  opacity: .16;
  transform: scale(0);
  animation: m3-ripple 450ms var(--m3-ease-standard-decelerate) forwards !important;
}
@keyframes m3-ripple { to { transform: scale(1); opacity: 0; } }

/* La pressione la anima JS (proprieta' `scale`, molla con rimbalzo al
   rilascio). Le vecchie regole :active con transform vanno neutralizzate:
   sulle card scattavano anche all'inizio di uno scroll. */
.btn-primary:active, .btn-tonal:active, .btn-tonal-appbar:active, .btn-icon:active,
.filter-chip:active, .cat-btn:active, .m3-nav-item:active, .btn-wizard-add:active,
.btn-wizard-nav:active, .btn-wizard-primary:active, .wizard-product-card:active,
.prod-card:active { transform: none !important; }

/* Badge sulle immagini: niente blur (un backdrop-filter per OGNI card
   visibile e' tra le cose piu' costose per una GPU mobile). */
.m3-badge { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }

/* Scrim M3: nero al 32%, senza blur, con dissolvenza */
.dialog-overlay, .full-modal, .cart-backdrop {
  background: rgba(0,0,0,.42) !important;
  backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
}
.dialog-overlay.open, .full-modal.open, .cart-backdrop.open, .sheet-scrim.open {
  /* backwards (non both): finita l'entrata lo scrim deve poter seguire il dito */
  animation: m3-fade-in var(--m3-dur-fade) var(--m3-ease-standard) backwards;
}
.dialog-overlay.closing, .full-modal.closing, .cart-backdrop.closing, .sheet-scrim.closing {
  animation: m3-fade-out var(--m3-dur-exit) var(--m3-ease-standard-accelerate) both !important;
}
@keyframes m3-fade-in  { from { opacity: 0; } to { opacity: 1; } }
/* solo `to`: l'uscita parte dal valore attuale (scrim gia' schiarito dal trascinamento) */
@keyframes m3-fade-out { to { opacity: 0; } }

/* Dialog desktop: dissolvenza + scala (M3 dialog) */
.dialog, .full-modal-card {
  animation: m3-dialog-in var(--m3-spring-spatial-dur) var(--m3-ease-emph-decelerate) backwards !important;
}
.dialog-overlay.closing .dialog, .full-modal.closing .full-modal-card {
  animation: m3-dialog-out var(--m3-dur-fade) var(--m3-ease-emph-accelerate) both !important;
}
@keyframes m3-dialog-in  { from { opacity: 0; transform: translateY(12px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes m3-dialog-out { to { opacity: 0; transform: scale(.97); } }

.sheet-handle { display: none; }

/* Snackbar e pillola aggiornamento: molla */
#snackbar { transition: transform var(--m3-spring-bouncy-dur) var(--m3-spring-bouncy) !important; }
.catalog-update-pill { transition: transform var(--m3-spring-bouncy-dur) var(--m3-spring-bouncy), opacity 150ms var(--m3-ease-standard) !important; }

@media (max-width: 840px) {
  /* Top bar: superficie piena invece del vetro sfocato. Il blur di 20 px
     andava ricalcolato a ogni frame di scroll dietro la barra sticky. */
  .top-app-bar {
    background: var(--md-sys-color-surface) !important;
    backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
  }
  .top-app-bar.scrolled { background: var(--md-sys-color-surface-container) !important; }
  [data-theme="light"] .top-app-bar { background: var(--md-sys-color-surface) !important; }
  [data-theme="light"] .top-app-bar.scrolled { background: var(--md-sys-color-surface-container) !important; }

  /* Bottom sheet (storico, wizard): entrano dal basso con la molla spaziale,
     escono accelerando; seguono il dito (--drag-y) e si chiudono trascinando. */
  .dialog, .full-modal-card {
    animation: m3-sheet-in var(--m3-spring-spatial-dur) var(--m3-spring-spatial) backwards !important;
    transform: translateY(var(--drag-y, 0px));
    will-change: transform;
  }
  .dialog-overlay.closing .dialog, .full-modal.closing .full-modal-card {
    animation: m3-sheet-out var(--m3-dur-exit) var(--m3-ease-emph-accelerate) both !important;
  }
  .sheet-handle {
    display: flex; justify-content: center; align-items: center;
    height: 22px; margin: -14px 0 4px; cursor: grab; touch-action: none;
  }
  .sheet-handle::before {
    content: ''; width: 32px; height: 4px; border-radius: 2px;
    background: var(--md-sys-color-on-surface-variant); opacity: .4;
  }

  /* Carrello: bottom sheet anche lui (prima scorreva da destra con gli
     angoli da bottom sheet) */
  .cart-drawer {
    top: auto !important; height: 92vh !important; height: 92dvh !important;
    /* +32px: la maniglia sporge sopra il bordo e restava visibile in fondo */
    transform: translateY(calc(100% + 32px)) !important;
    visibility: hidden;
    transition: transform var(--m3-dur-exit) var(--m3-ease-emph-accelerate), visibility 0s linear var(--m3-dur-exit) !important;
  }
  .cart-drawer.open {
    transform: translateY(var(--drag-y, 0px)) !important;
    visibility: visible;
    transition: transform var(--m3-spring-spatial-dur) var(--m3-spring-spatial), visibility 0s !important;
  }
  /* durante il trascinamento nessuna transizione: il foglio sta sotto il dito */
  .cart-drawer.open.dragging, .page-sidebar.open.dragging { transition: none !important; }

  /* Reparti: stesso modello. Prima la transform era !important e il
     trascinamento (inline) non si vedeva: il foglio non seguiva il dito. */
  .page-sidebar {
    transform: translateY(calc(100% + 32px)) !important;
    visibility: hidden;
    transition: transform var(--m3-dur-exit) var(--m3-ease-emph-accelerate), visibility 0s linear var(--m3-dur-exit) !important;
  }
  .page-sidebar.open {
    transform: translateY(var(--drag-y, 0px)) !important;
    visibility: visible;
    transition: transform var(--m3-spring-spatial-dur) var(--m3-spring-spatial), visibility 0s !important;
  }
  .sheet-scrim { background: rgba(0,0,0,.42) !important; }

  /* Indicatore della nav bar: larghezza fissa + scaleX (compositor) con
     molla espressiva, invece di animare `width` (layout a ogni frame). */
  .m3-nav-pill {
    width: 56px !important;
    transform: scaleX(.4); opacity: 0;
    transition: transform var(--m3-spring-bouncy-dur) var(--m3-spring-bouncy),
                opacity 120ms var(--m3-ease-standard) !important;
  }
  .m3-nav-item.active .m3-nav-pill { transform: scaleX(1); opacity: 1; }
}

@keyframes m3-sheet-in  { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes m3-sheet-out { to { transform: translateY(100%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}

/* Segnaposto del riepilogo storico mentre arrivano i dati */
.ps-tile.ps-skel {
  height: 66px;
  background: linear-gradient(90deg, var(--md-sys-color-surface-container) 25%, var(--md-sys-color-surface-container-high) 50%, var(--md-sys-color-surface-container) 75%);
  background-size: 200% 100%; animation: sk-shimmer 1.3s ease-in-out infinite;
}

/* Reparti: 843 righe (~6.000 elementi) nel foglio. Le righe fuori vista non
   vengono impaginate ne' dipinte finche' non ci si scorre sopra. */
/* (17/10) content-visibility:auto sulle righe dei reparti RIMOSSO: mentre il
   foglio sale le righe entrano nel viewport e venivano impaginate frame per
   frame (33 ms a frame durante l'animazione, misurato). */

/* ═══════════════════════════════════════════════════════════════
   CARRELLO, BLOCCO SCROLL, SNACKBAR (build 20261017-4)
   ═══════════════════════════════════════════════════════════════ */

/* Blocco dello scroll su <html> (vedi ptpScrollLock in app.js): con
   overflow-x:clip su html il solo body{overflow:hidden} non bastava piu'. */
html.ptp-scroll-locked { overscroll-behavior: none; }
/* overflow:hidden solo su desktop (rotella). Su mobile bloccano i gestori
   touch dei fogli: cambiare overflow di html rifaceva il layout di tutta la
   pagina nel primo frame dell'animazione (vedi ptpScrollLock). */
@media (min-width: 841px) { html.ptp-scroll-locked { overflow: hidden !important; } }
.cart-backdrop, .sheet-scrim { touch-action: none; }

/* Carrello: header fisso, UNA area scorrevole (prodotti + riepilogo),
   barra in basso sempre visibile con totale e azione principale. */
.cart-scroll {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column;
}
.cart-scroll .cart-items-list { flex: none; overflow: visible; }
.cart-scroll .cart-footer { border-top: none; background: transparent; padding-top: 4px; }
.cart-bottom-bar {
  flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--md-sys-color-surface-container);
  border-top: 1px solid var(--md-sys-color-outline-variant);
}
.cart-bar-total { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.cart-bar-label { font-size: .72rem; font-weight: 600; color: var(--md-sys-color-on-surface-variant); }
.cart-bar-total strong {
  font-family: 'Google Sans Display', 'Google Sans', sans-serif;
  font-size: 1.3rem; color: var(--md-sys-color-secondary); font-variant-numeric: tabular-nums;
}
.cart-bar-saving { font-size: .74rem; font-weight: 700; color: #22c55e; }
.cart-bottom-bar .btn-cart-open-all { flex: 1; min-width: 0; height: 48px; border-radius: 24px; }
.cart-bottom-bar .cart-openall-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 840px) {
  /* Foglio a tutta altezza (meno la status bar): piu' prodotti visibili */
  .cart-drawer {
    height: calc(100vh - 12px) !important;
    height: calc(100dvh - env(safe-area-inset-top, 0px) - 12px) !important;
  }
  .cart-drawer-header { padding: 4px 16px 10px !important; }

  /* Riepilogo compatto: 3 numeri su una riga (prima 4 schede = 432 px) */
  .cart-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 6px !important; }
  .cart-summary-grid > .cart-summary-cell:last-child { display: none !important; } /* articoli/pezzi: gia' nel badge */
  .cart-summary-cell { padding: 8px 10px !important; }
  .cart-summary-label { font-size: .62rem !important; letter-spacing: .3px !important; }
  .cart-summary-value, .cart-saving-amount { font-size: 1rem !important; }
  .cart-saving-cell { flex-direction: column !important; align-items: flex-start !important; gap: 2px !important; }
  .cart-saving-pct { font-size: .66rem !important; padding: 1px 6px !important; }

  /* Riga prodotto compatta, comandi da 40 px */
  .cart-items-list { padding: 10px 12px !important; gap: 8px !important; }
  .cart-item { padding: 10px 12px !important; gap: 10px !important; }
  .cart-item-img { width: 52px !important; height: 52px !important; flex-shrink: 0; }
  .cart-item-name { -webkit-line-clamp: 2; }
  .cart-item-controls { gap: 6px !important; justify-content: flex-start !important; flex-wrap: nowrap !important; }
  .cart-item-stepper-btn { width: 36px !important; height: 36px !important; }
  .cart-item-subtotal { white-space: nowrap; margin-right: auto; font-weight: 700; }
  .cart-item-open-btn { font-size: 0 !important; gap: 0 !important; width: 40px; height: 36px; justify-content: center; padding: 0 !important; }
  .cart-item-open-btn svg { width: 16px; height: 16px; }
  .cart-item-remove { width: 40px; height: 36px; display: inline-flex; align-items: center; justify-content: center; }
}

/* Snackbar M3: nascosta DAVVERO (opacita' 0 + fuori dal flusso visivo).
   Prima era solo spostata di 80 px: un messaggio su piu' righe restava in
   parte visibile sopra la bottom nav, per sempre. Su mobile sta sopra la
   barra di navigazione, larga quanto lo schermo meno i margini. */
#snackbar {
  opacity: 0; visibility: hidden;
  transform: translateX(-50%) translateY(16px);
  transition: transform 200ms var(--m3-ease-emph-accelerate), opacity 150ms linear, visibility 0s linear 200ms !important;
  max-width: min(560px, calc(100vw - 32px));
  line-height: 1.4;
}
#snackbar.show {
  opacity: 1; visibility: visible;
  transform: translateX(-50%) translateY(0);
  transition: transform var(--m3-spring-bouncy-dur) var(--m3-spring-bouncy), opacity 120ms linear, visibility 0s !important;
}
@media (max-width: 840px) {
  #snackbar {
    left: 12px; right: 12px; width: auto; max-width: none;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 12px);
    transform: translateY(16px);
  }
  #snackbar.show { transform: translateY(0); }
}

@media (max-width: 840px) {
  /* maniglia del carrello dentro il foglio (con il margine negativo finiva
     sopra il bordo, fuori schermo) */
  .cart-drawer > .sheet-handle { margin: 0; height: 20px; flex: none; }
}
.dialog, .full-modal, .full-modal-body, .cart-scroll, .category-list { overscroll-behavior: contain; }

/* ═══ Bottom sheet M3 — rifinitura (build 20261017-5) ═══════════════════ */
/* --drag-y NON ereditata: cambiarla a ogni movimento del dito non deve
   ricalcolare lo stile di tutti i discendenti del foglio (843 righe nei
   reparti). */
@property --drag-y { syntax: '<length>'; inherits: false; initial-value: 0px; }

@media (max-width: 840px) {
  /* Maniglia visibile anche nel wizard: con il margine negativo finiva fuori
     dalla card (overflow:hidden) e non si vedeva. */
  .full-modal-card > .sheet-handle { margin: 0; height: 24px; flex: none; padding-top: 2px; }
  .dialog > .sheet-handle { margin: -12px 0 2px; }

  /* Rilascio senza chiusura: il foglio torna su con la molla (prima
     scattava di colpo in posizione). */
  .dialog, .full-modal-card {
    transition: transform var(--m3-spring-spatial-dur) var(--m3-spring-spatial);
  }
  .dialog.dragging, .full-modal-card.dragging { transition: none !important; }
  .dialog, .full-modal-card, .cart-drawer, .page-sidebar { will-change: transform; }

  /* Niente scroll a catena verso la pagina da nessun contenitore dei fogli */
  .page-sidebar, .dialog, .full-modal-card, .full-modal-body, .cart-scroll, .category-list {
    overscroll-behavior: contain;
  }
}

/* Scrim che si schiarisce mentre il foglio viene trascinato giu' (M3).
   Per i dialog lo scrim e' lo sfondo dell'overlay che contiene il foglio:
   si agisce sull'alfa con una proprieta' registrata, non sull'opacita'
   (che sbiadirebbe anche il foglio). */
@property --scrim { syntax: '<number>'; inherits: false; initial-value: 1; }
.dialog-overlay, .full-modal { background: rgba(0,0,0, calc(.42 * var(--scrim))) !important; transition: --scrim 250ms var(--m3-ease-standard); }
.cart-backdrop, .sheet-scrim { transition: opacity 250ms var(--m3-ease-standard); }
.sheet-dragging-scrim { transition: none !important; }

/* Overlay che CONTENGONO il foglio (storico, wizard): si anima solo l'alfa
   dello scrim, non l'opacita' dell'overlay. Prima entrando e uscendo il
   foglio stesso diventava semitrasparente insieme allo sfondo. */
@keyframes m3-scrim-in { from { --scrim: 0; } }
@keyframes m3-scrim-out { to { --scrim: 0; } }
.dialog-overlay.open, .full-modal.open {
  animation: m3-scrim-in 250ms var(--m3-ease-standard) backwards !important;
}
.dialog-overlay.closing, .full-modal.closing {
  animation: m3-scrim-out var(--m3-dur-exit) var(--m3-ease-standard-accelerate) forwards !important;
}
