/* =========================================================
   Richiami Alimentari 33% — design system
   Palette dal brand trentatrepercento.com
   ========================================================= */
:root {
  --brand: #2e7d32;
  --brand-600: #276c2b;
  --brand-700: #1b5e20;
  --brand-900: #1a3d1a;
  --brand-100: #e8f5e9;
  --brand-50: #f1f8e9;
  --lime: #84cc16;
  --sky: #1e88e5;
  --accent: #f9a825;
  --accent-600: #f29100;

  --bg: #f5f7f3;
  --surface: #ffffff;
  --surface-2: #eef3ec;
  --text: #13221a;
  --muted: #5d6d63;
  --border: #e1e8df;
  --shadow-sm: 0 1px 2px rgba(19, 34, 26, .06), 0 1px 1px rgba(19, 34, 26, .04);
  --shadow: 0 10px 30px -12px rgba(27, 94, 32, .25), 0 2px 6px rgba(19, 34, 26, .05);
  --radius: 18px;
  --radius-sm: 12px;
  --header-h: 68px;
  --tabbar-h: 64px;

  --c-micro: #e53935;
  --c-allergeni: #f59e0b;
  --c-chimico: #8e24aa;
  --c-fisico: #1e88e5;
  --c-materiali: #00897b;
  --c-altro: #607d8b;
  --c-revoca: #2e7d32;
  --c-avviso: #283593;

  --bs-body-font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-link-color: var(--brand);
  --bs-link-color-rgb: 46, 125, 50;
  --bs-link-hover-color: var(--brand-700);
  --bs-link-hover-color-rgb: 27, 94, 32;
  --bs-border-color: var(--border);
  --bs-primary: var(--brand);
  --bs-primary-rgb: 46, 125, 50;
}

[data-bs-theme="dark"] {
  --bg: #0c130f;
  --surface: #131d17;
  --surface-2: #1a2620;
  --text: #e5eee8;
  --muted: #9aab9f;
  --border: #25332b;
  --brand-100: #173321;
  --brand-50: #13261a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
  --c-avviso: #7986cb;
  --c-chimico: #ba68c8;
  --c-revoca: #66bb6a;
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-link-color: #81c784;
  --bs-link-color-rgb: 129, 199, 132;
  --bs-link-hover-color: #a5d6a7;
  --bs-border-color: var(--border);
  --bs-secondary-color: var(--muted);
}

html { scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  overflow-x: clip;
  font-family: var(--bs-body-font-family);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.app-main { flex: 1 0 auto; padding-bottom: 2.5rem; }
a { text-underline-offset: 3px; }
.text-brand { color: var(--brand) !important; }
.text-avviso { color: var(--c-avviso) !important; }
.text-body-secondary { color: var(--muted) !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }

/* ---------- Buttons ---------- */
.btn { font-weight: 600; }
.btn-brand { --bs-btn-color: #fff; --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--brand-700); --bs-btn-hover-border-color: var(--brand-700); --bs-btn-active-bg: var(--brand-900); --bs-btn-active-color: #fff; --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-outline-brand { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand-700); --bs-btn-active-color: #fff; }
[data-bs-theme="dark"] .btn-outline-brand { --bs-btn-color: #81c784; --bs-btn-border-color: #4f8f53; }
.btn-accent { --bs-btn-color: #1a1a1a; --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: var(--accent-600); --bs-btn-hover-border-color: var(--accent-600); --bs-btn-hover-color: #111; --bs-btn-active-bg: var(--accent-600); }
.btn-soft { --bs-btn-color: var(--text); --bs-btn-bg: var(--surface-2); --bs-btn-border-color: var(--border); --bs-btn-hover-bg: var(--brand-100); --bs-btn-hover-color: var(--brand-700); --bs-btn-hover-border-color: var(--brand-100); }
[data-bs-theme="dark"] .btn-soft { --bs-btn-hover-color: #a5d6a7; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 1.1rem; text-decoration: none;
  transition: background .15s, color .15s;
}
.icon-btn:hover, .icon-btn.active { background: var(--brand-100); color: var(--brand-700); }
[data-bs-theme="dark"] .icon-btn:hover, [data-bs-theme="dark"] .icon-btn.active { color: #a5d6a7; }

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 1030; height: var(--header-h);
  display: flex; align-items: center; padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--text); flex-shrink: 0; }
.brand-logo { border-radius: 50%; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; }
.brand-sub { font-size: .78rem; color: var(--muted); font-weight: 600; }
.brand-sub b { color: var(--brand); }
.main-nav { gap: .25rem; margin-left: 1.25rem; }
.main-nav a {
  display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .85rem; border-radius: 999px;
  color: var(--muted); font-weight: 600; font-size: .93rem; text-decoration: none; transition: background .15s, color .15s;
}
.main-nav a:hover { color: var(--text); background: var(--surface-2); }
.main-nav a.active { color: var(--brand-700); background: var(--brand-100); }
[data-bs-theme="dark"] .main-nav a.active { color: #a5d6a7; }
.nav-count { background: var(--brand); color: #fff; font-size: .7rem; border-radius: 999px; padding: .05rem .4rem; }
.header-search { position: relative; align-items: center; }
.header-search i { position: absolute; left: .85rem; color: var(--muted); }
.header-search input {
  width: 260px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 999px; padding: .5rem 1rem .5rem 2.3rem; font-size: .9rem; transition: width .2s, background .2s;
}
.header-search input:focus { outline: none; width: 320px; background: var(--surface); border-color: var(--brand); }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden; color: #fff; padding: 3rem 0 3.25rem;
  background:
    radial-gradient(900px 400px at 85% -10%, rgba(132, 204, 22, .35), transparent 60%),
    radial-gradient(700px 380px at -10% 120%, rgba(30, 136, 229, .30), transparent 60%),
    linear-gradient(135deg, var(--brand-700) 0%, var(--brand) 55%, #3c8f2f 100%);
}
.hero::after {
  content: ""; position: absolute; right: -120px; top: -120px; width: 420px; height: 420px; border-radius: 50%;
  border: 46px solid rgba(255, 255, 255, .06); pointer-events: none;
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: .5rem; font-size: .8rem; font-weight: 700; letter-spacing: .02em;
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .2); padding: .35rem .8rem; border-radius: 999px;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #b9f6ca; box-shadow: 0 0 0 0 rgba(185, 246, 202, .8); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(185, 246, 202, 0); } 100% { box-shadow: 0 0 0 0 rgba(185, 246, 202, 0); } }
.hero-title { font-weight: 800; font-size: clamp(2rem, 5vw, 3.3rem); letter-spacing: -.035em; line-height: 1.05; margin: 1rem 0 .8rem; }
.hero-title span { color: #d6f5a3; }
.hero-lead { font-size: 1.08rem; opacity: .92; max-width: 560px; }
.hero-search {
  position: relative; display: flex; align-items: center; background: #fff; border-radius: 999px; padding: .35rem;
  max-width: 580px; box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .45); margin-top: 1.4rem;
}
.hero-search i { position: absolute; left: 1.15rem; color: #6b7a70; font-size: 1.1rem; }
.hero-search input { flex: 1; border: 0; outline: 0; padding: .7rem .8rem .7rem 2.8rem; font-size: 1.02rem; background: transparent; color: #13221a; min-width: 0; }
.hero-search .btn { border-radius: 999px; padding: .6rem 1.4rem; }
.hero-sync { font-size: .85rem; opacity: .8; margin: .9rem 0 0; }
.kpi-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.kpi {
  display: flex; flex-direction: column; gap: .15rem; padding: 1.1rem 1.2rem; border-radius: var(--radius);
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .18); color: #fff; text-decoration: none;
  backdrop-filter: blur(6px);
}
.kpi-main { grid-column: 1 / -1; background: #fff; color: var(--brand-900); transition: transform .15s; }
.kpi-main:hover { transform: translateY(-2px); color: var(--brand-900); }
.kpi-label { font-size: .82rem; font-weight: 600; opacity: .85; }
.kpi-value { font-size: 2.1rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.kpi-main .kpi-value { font-size: 3rem; color: var(--brand); }
.kpi-delta { font-size: .82rem; font-weight: 700; }
.kpi-delta.up { color: #c62828; }
.kpi-delta.down { color: var(--brand); }

/* ---------- Chips ---------- */
.chip-scroller { display: flex; gap: .5rem; overflow-x: auto; padding: 1.25rem 0 .25rem; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chip-scroller::-webkit-scrollbar { display: none; }
.chip-scroller-tight { padding: .75rem 0 0; }
.chip-wrap { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  --chip: var(--brand);
  display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; padding: .5rem .95rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 600; font-size: .88rem;
  text-decoration: none; box-shadow: var(--shadow-sm); transition: all .15s; cursor: pointer; user-select: none;
}
.chip i { color: var(--chip); }
.chip:hover { border-color: var(--chip); color: var(--text); }
.chip.active, .chip-check:has(input:checked) { background: var(--chip); border-color: var(--chip); color: #fff; }
.chip.active i, .chip-check:has(input:checked) i { color: #fff; }
.chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-micro { --chip: var(--c-micro); } .chip-allergeni { --chip: var(--c-allergeni); } .chip-chimico { --chip: var(--c-chimico); }
.chip-fisico { --chip: var(--c-fisico); } .chip-materiali { --chip: var(--c-materiali); } .chip-altro { --chip: var(--c-altro); }
.chip-revoca { --chip: var(--c-revoca); } .chip-avviso { --chip: var(--c-avviso); }

/* ---------- Category colors ---------- */
.cat-micro { --cat: var(--c-micro); } .cat-allergeni { --cat: var(--c-allergeni); } .cat-chimico { --cat: var(--c-chimico); }
.cat-fisico { --cat: var(--c-fisico); } .cat-materiali { --cat: var(--c-materiali); } .cat-altro { --cat: var(--c-altro); }
.cat-revoca { --cat: var(--c-revoca); } .cat-avviso { --cat: var(--c-avviso); }
.bg-cat-micro { background: var(--c-micro); } .bg-cat-allergeni { background: var(--c-allergeni); } .bg-cat-chimico { background: var(--c-chimico); }
.bg-cat-fisico { background: var(--c-fisico); } .bg-cat-materiali { background: var(--c-materiali); } .bg-cat-altro { background: var(--c-altro); }
.bg-cat-revoca { background: var(--c-revoca); } .bg-cat-avviso { background: var(--c-avviso); }
.cat-badge {
  display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; font-weight: 700; padding: .22rem .6rem; border-radius: 999px;
  color: var(--cat); background: color-mix(in srgb, var(--cat) 12%, transparent); border: 1px solid color-mix(in srgb, var(--cat) 22%, transparent);
}
.new-badge { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; padding: .2rem .5rem; border-radius: 6px; background: var(--accent); color: #1a1a1a; }
.arch-badge { font-size: .7rem; font-weight: 700; padding: .2rem .5rem; border-radius: 6px; background: var(--surface-2); color: var(--muted); }

/* ---------- Sections ---------- */
.section { margin-top: 2rem; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-head h2 { font-weight: 800; letter-spacing: -.02em; margin: 0; }
.section-head h2:not([class*="h"]) { font-size: 1.5rem; }
.section-link { font-weight: 700; text-decoration: none; font-size: .92rem; white-space: nowrap; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.35rem; box-shadow: var(--shadow-sm); }
.panel-title { font-size: 1.1rem; font-weight: 800; letter-spacing: -.01em; margin-bottom: .25rem; }
.panel-sub { color: var(--muted); font-size: .88rem; margin-bottom: 1rem; }
.page-head { padding: 2rem 0 .5rem; }
.page-title { font-weight: 800; letter-spacing: -.035em; font-size: clamp(1.8rem, 4vw, 2.5rem); margin-bottom: .3rem; }
.page-sub { color: var(--muted); margin-bottom: 0; max-width: 680px; }

/* ---------- Recall card ---------- */
.rcard {
  position: relative; height: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); transition: transform .18s ease, box-shadow .18s ease, border-color .18s; overflow: hidden;
}
.rcard:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--brand) 25%, var(--border)); }
.rcard-link { display: flex; gap: .95rem; padding: .9rem; height: 100%; color: inherit; text-decoration: none; }
.rcard-link:hover { color: inherit; }
.rcard-media {
  flex: 0 0 96px; height: 96px; border-radius: 14px; overflow: hidden; display: grid; place-items: center;
  background: color-mix(in srgb, var(--cat) 10%, var(--surface-2)); color: var(--cat); font-size: 2rem;
}
.rcard-media img { width: 100%; height: 100%; object-fit: cover; background: #fff; }
.rcard-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: .3rem; padding-right: 1.6rem; }
.rcard-meta { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.rcard-date { font-size: .78rem; color: var(--muted); font-weight: 600; margin-left: auto; }
.rcard-title { font-size: 1rem; font-weight: 700; line-height: 1.3; margin: .1rem 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; letter-spacing: -.01em; }
.rcard-brand { font-size: .85rem; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rcard-lotto { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: auto; }
.rcard-lotto span { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text); background: var(--surface-2); padding: .05rem .35rem; border-radius: 5px; }
.fav-btn {
  position: absolute; top: .55rem; right: .55rem; width: 34px; height: 34px; border-radius: 50%; border: 0;
  background: transparent; color: var(--muted); display: grid; place-items: center; font-size: 1.05rem; z-index: 2; transition: all .15s;
}
.fav-btn:hover { background: var(--surface-2); color: var(--brand); }
.fav-btn.saved { color: var(--brand); }
.fav-btn.saved i::before { content: "\f199"; } /* bookmark-fill */
.pantry-flag { display: none; font-size: .75rem; font-weight: 700; color: #8a5a00; background: #fff4d6; border-radius: 6px; padding: .15rem .45rem; align-self: flex-start; }
[data-bs-theme="dark"] .pantry-flag { background: #3a2f12; color: #ffd54f; }
.rcard.in-pantry { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent); }
.rcard.in-pantry .pantry-flag { display: inline-flex; gap: .3rem; align-items: center; }
.load-more-wrap { text-align: center; padding-top: 1rem; }

/* ---------- Mini list ---------- */
.mini-list { list-style: none; padding: 0; margin: 0; }
.mini-list li + li { border-top: 1px solid var(--border); }
.mini-list a { display: flex; flex-direction: column; padding: .7rem 0; text-decoration: none; color: inherit; }
.mini-list a:hover .mini-title { color: var(--brand); }
.mini-title { font-weight: 700; font-size: .95rem; line-height: 1.3; }
.mini-meta { font-size: .8rem; color: var(--muted); }

/* ---------- Promo ---------- */
.promo { display: flex; align-items: center; gap: 1rem; padding: 1.2rem 1.35rem; border-radius: var(--radius); text-decoration: none; transition: transform .15s; height: 100%; }
.promo:hover { transform: translateY(-2px); }
.promo strong { display: block; font-size: 1.05rem; }
.promo span { font-size: .88rem; opacity: .9; }
.promo-icon { font-size: 1.6rem; width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; flex-shrink: 0; }
.promo-brand { background: linear-gradient(135deg, var(--brand-700), var(--brand)); color: #fff; }
.promo-brand:hover { color: #fff; }
.promo-brand .promo-icon { background: rgba(255, 255, 255, .16); }
.promo-light { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.promo-light:hover { color: var(--text); }
.promo-light .promo-icon { background: #fff4d6; color: #b07a00; }
[data-bs-theme="dark"] .promo-light .promo-icon { background: #3a2f12; color: #ffd54f; }

/* ---------- Filters ---------- */
.filters-bar {
  position: sticky; top: var(--header-h); z-index: 1020; padding: .75rem 0 .6rem; margin-bottom: 1rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.filters { display: flex; gap: .5rem; }
.filters-search { position: relative; flex: 1; min-width: 0; }
.filters-search i { position: absolute; left: .95rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.filters-search input, .filters .form-select {
  height: 46px; border-radius: 14px; border: 1px solid var(--border); background-color: var(--surface); color: var(--text); font-weight: 500;
}
.filters-search input { width: 100%; padding: 0 1rem 0 2.5rem; }
.filters-search input:focus, .filters .form-select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 15%, transparent); }
.filters .form-select { width: auto; max-width: 170px; }
.filters-submit { border-radius: 14px; height: 46px; padding: 0 1rem; }
.chip-scroller-tight .chip { padding: .38rem .8rem; font-size: .82rem; box-shadow: none; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 4rem 1rem; max-width: 520px; margin: 0 auto; }
.empty-state > i { font-size: 3rem; color: var(--brand); display: inline-grid; place-items: center; width: 88px; height: 88px; border-radius: 50%; background: var(--brand-100); margin-bottom: 1rem; }
.empty-state h1, .empty-state h2 { font-weight: 800; font-size: 1.5rem; }
.empty-state p { color: var(--muted); }

/* ---------- Detail ---------- */
.detail { padding-top: 1.25rem; }
.back-link { display: inline-flex; align-items: center; gap: .4rem; font-weight: 700; text-decoration: none; margin-bottom: 1rem; color: var(--muted); }
.back-link:hover { color: var(--brand); }
.gallery { position: sticky; top: calc(var(--header-h) + 1rem); }
.gallery-main { background: #fff; border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; aspect-ratio: 4 / 3.2; display: grid; place-items: center; box-shadow: var(--shadow-sm); }
.gallery-main img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.gallery-thumbs { display: flex; gap: .5rem; margin-top: .6rem; }
.gallery-thumbs button { width: 72px; height: 60px; padding: 0; border-radius: 10px; border: 2px solid var(--border); overflow: hidden; background: #fff; }
.gallery-thumbs button.active { border-color: var(--brand); }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.gallery-note { font-size: .75rem; color: var(--muted); margin: .5rem 0 0; }
.gallery-placeholder {
  aspect-ratio: 4 / 3; border-radius: var(--radius); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .8rem;
  background: radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--cat) 22%, transparent), transparent 60%), color-mix(in srgb, var(--cat) 9%, var(--surface));
  color: var(--cat); border: 1px solid color-mix(in srgb, var(--cat) 20%, var(--border)); font-weight: 700; text-align: center; padding: 1rem;
}
.gallery-placeholder i { font-size: 4.5rem; }
.detail-kicker { color: var(--muted); font-size: .9rem; font-weight: 600; margin: .3rem 0 .2rem; }
.detail-title { font-weight: 800; letter-spacing: -.03em; font-size: clamp(1.6rem, 3.6vw, 2.3rem); line-height: 1.12; margin-bottom: .35rem; }
.detail-brand { font-size: 1.1rem; font-weight: 600; color: var(--muted); }
.detail-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.1rem 0 1.4rem; }
.detail-actions [data-fav].saved { --bs-btn-bg: var(--brand-700); }
.detail-actions [data-fav].saved i::before { content: "\f199"; }
.callout { display: flex; gap: .9rem; padding: 1rem 1.15rem; border-radius: var(--radius-sm); margin-bottom: 1rem; --cat: var(--c-altro);
  background: color-mix(in srgb, var(--cat) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--cat) 25%, transparent); }
.callout > i { color: var(--cat); font-size: 1.4rem; line-height: 1.2; }
.callout strong { display: block; margin-bottom: .15rem; }
.callout p { margin: 0; }
.callout-micro { --cat: var(--c-micro); } .callout-allergeni { --cat: var(--c-allergeni); } .callout-chimico { --cat: var(--c-chimico); }
.callout-fisico { --cat: var(--c-fisico); } .callout-materiali { --cat: var(--c-materiali); } .callout-altro { --cat: var(--c-altro); }
.callout-revoca { --cat: var(--c-revoca); } .callout-avviso { --cat: var(--c-avviso); } .callout-warning { --cat: var(--accent-600); }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.fact { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .75rem .9rem; min-width: 0; }
.fact dt { font-size: .76rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .2rem; }
.fact dt i { color: var(--brand); }
.fact dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.fact-key { grid-column: span 2; background: var(--brand-50); border-color: color-mix(in srgb, var(--brand) 25%, transparent); }
.fact-key dd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.02rem; }
.facts-compact { grid-template-columns: 1fr 1fr; }
.pdf-preview { margin: 1rem 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.pdf-preview summary { padding: .8rem 1rem; font-weight: 700; cursor: pointer; }
.pdf-preview object { width: 100%; height: 720px; border-top: 1px solid var(--border); display: block; }
.detail-source { font-size: .82rem; color: var(--muted); margin-top: 1rem; }

/* ---------- Stats ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; display: flex; flex-direction: column; box-shadow: var(--shadow-sm); }
.stat-label { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 2.2rem; font-weight: 800; letter-spacing: -.03em; color: var(--brand); line-height: 1.15; }
.stat-sub { font-size: .82rem; color: var(--muted); }
.chart-box { position: relative; height: 300px; }
.chart-box-sm { height: 220px; }
.legend-list { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .35rem; font-size: .88rem; }
.legend-list li { display: flex; align-items: center; gap: .5rem; }
.legend-list b { margin-left: auto; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.bar-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .55rem; }
.bar-list li { display: grid; grid-template-columns: minmax(0, 11rem) 1fr 2.5rem; align-items: center; gap: .75rem; font-size: .88rem; }
.bar-label { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: inherit; text-decoration: none; }
a.bar-label:hover { color: var(--brand); }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand), var(--lime)); }
.bar-fill-alt { background: linear-gradient(90deg, var(--sky), #4fc3f7); }
.bar-list b { text-align: right; }

/* ---------- Pantry / notifications ---------- */
.seg-tabs { display: inline-flex; gap: .25rem; background: var(--surface-2); padding: .3rem; border-radius: 999px; margin-bottom: 1rem; border: 1px solid var(--border); }
.seg-tabs button { border: 0; background: transparent; color: var(--muted); font-weight: 700; padding: .5rem 1rem; border-radius: 999px; font-size: .9rem; }
.seg-tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg-count { background: var(--brand); color: #fff; border-radius: 99px; font-size: .7rem; padding: .05rem .4rem; }
.watch-form { position: relative; display: flex; gap: .5rem; align-items: center; }
.watch-form i { position: absolute; left: 1rem; color: var(--brand); font-size: 1.1rem; }
.watch-form input { flex: 1; min-width: 0; height: 48px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); padding: 0 1rem 0 2.6rem; }
.watch-form input:focus { outline: none; border-color: var(--brand); background: var(--surface); }
.watch-form .btn { height: 48px; padding: 0 1.25rem; }
.watch-chips { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .9rem; }
.watch-chip { display: inline-flex; align-items: center; gap: .35rem; background: var(--brand-100); color: var(--brand-700); font-weight: 700; border-radius: 999px; padding: .35rem .45rem .35rem .85rem; font-size: .88rem; }
[data-bs-theme="dark"] .watch-chip { color: #a5d6a7; }
.watch-chip button { border: 0; background: rgba(0, 0, 0, .06); color: inherit; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; }
.watch-group { margin-bottom: 1.5rem; }
.watch-group h3 { font-size: 1rem; font-weight: 800; display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.watch-group h3 .badge { background: var(--surface-2); color: var(--muted); font-weight: 700; }
.notify-status { display: flex; gap: 1rem; align-items: center; }
.notify-status strong { display: block; font-size: 1.1rem; }
.notify-status span:not(.notify-icon) { color: var(--muted); font-size: .9rem; }
.notify-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; font-size: 1.6rem; background: var(--surface-2); color: var(--muted); flex-shrink: 0; }
.notify-status.on .notify-icon { background: var(--brand-100); color: var(--brand); }
.ios-hint { margin-top: 1.25rem; padding: 1rem; border-radius: var(--radius-sm); background: var(--surface-2); font-size: .9rem; }
.ios-hint ol { margin: .5rem 0 0; padding-left: 1.2rem; }
.pref-group { display: grid; gap: .5rem; margin: 1rem 0 1.25rem; }
.pref-title { font-size: .95rem; font-weight: 800; margin: 1.25rem 0 .6rem; }
.pref-title small { font-weight: 500; color: var(--muted); }
.pref-switch { display: flex; gap: .85rem; align-items: center; padding: .75rem .9rem; border-radius: var(--radius-sm); border: 1px solid var(--border); cursor: pointer; background: var(--surface); }
.pref-switch:has(input:checked) { border-color: color-mix(in srgb, var(--brand) 40%, transparent); background: var(--brand-50); }
.pref-switch input { appearance: none; width: 44px; height: 26px; border-radius: 99px; background: var(--border); position: relative; flex-shrink: 0; transition: background .2s; cursor: pointer; }
.pref-switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.pref-switch input:checked { background: var(--brand); }
.pref-switch input:checked::after { transform: translateX(18px); }
.pref-switch b { display: block; font-size: .95rem; }
.pref-switch small { color: var(--muted); }
.prose p, .prose li { color: var(--text); }
.prose .panel-title:not(:first-child) { margin-top: 1.25rem; }

/* ---------- Footer ---------- */
.app-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 2.25rem 0 2rem; margin-top: 2rem; }
.app-footer a { text-decoration: none; }
.app-footer li { margin-bottom: .35rem; }
.footer-title { font-weight: 800; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .6rem; }

/* ---------- Mobile tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1040; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--border);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem; text-decoration: none; color: var(--muted); font-size: .68rem; font-weight: 700; }
.tab-icon { position: relative; font-size: 1.3rem; width: 52px; height: 30px; display: grid; place-items: center; border-radius: 99px; transition: background .15s; }
.tabbar a.active { color: var(--brand-700); }
[data-bs-theme="dark"] .tabbar a.active { color: #a5d6a7; }
.tabbar a.active .tab-icon { background: var(--brand-100); }
.tab-badge { position: absolute; top: -2px; right: 6px; background: var(--accent); color: #1a1a1a; font-size: .6rem; font-weight: 800; border-radius: 99px; padding: 0 .3rem; line-height: 1.4; }
.app-toasts { bottom: calc(1rem + env(safe-area-inset-bottom)); z-index: 1090; }
.app-toasts .toast { background: var(--text); color: var(--bg); border: 0; border-radius: 999px; box-shadow: var(--shadow); }
.app-toasts .toast-body { padding: .7rem 1.2rem; font-weight: 600; display: flex; gap: .5rem; align-items: center; }

@media (max-width: 991.98px) {
  body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .app-toasts { bottom: calc(var(--tabbar-h) + 1rem + env(safe-area-inset-bottom)); }
  .app-footer { margin-top: 1rem; }
  .gallery { position: static; }
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767.98px) {
  :root { --header-h: 60px; }
  .container-xl { --bs-gutter-x: 2rem; }
  .brand-logo { width: 38px; height: 38px; }
  .hero { padding: 2rem 0 2.25rem; }
  .hero-search .btn { padding: .6rem 1rem; }
  .kpi-value { font-size: 1.7rem; }
  .kpi-main .kpi-value { font-size: 2.4rem; }
  .filters { flex-wrap: wrap; }
  .filters-search { flex: 1 1 100%; }
  .filters .form-select { flex: 1; max-width: none; }
  .rcard-media { flex-basis: 84px; height: 84px; }
  .facts { grid-template-columns: 1fr; }
  .fact-key { grid-column: auto; }
  .bar-list li { grid-template-columns: minmax(0, 8rem) 1fr 2rem; }
  .stat-value { font-size: 1.8rem; }
  .section-head h2:not([class*="h"]) { font-size: 1.3rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media (display-mode: standalone) and (max-width: 991.98px) {
  .app-footer { display: none; }
}
@media (max-width: 575.98px) {
  .kpi { padding: .85rem .9rem; }
  .kpi-value { font-size: 1.45rem; }
  .kpi-label { font-size: .74rem; }
}

/* =========================================================
   33% — app unica: home, scan, carrello, analisi, ricette, profilo
   ========================================================= */
.narrow { max-width: 760px; }
.min-w-0 { min-width: 0; }
.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.cat-brand { --cat: var(--brand); }

/* Icone colorate */
.action-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-size: 1.25rem; flex-shrink: 0;
  color: var(--cat); background: color-mix(in srgb, var(--cat) 12%, var(--surface)); }

/* Scanner */
.scanner { position: relative; aspect-ratio: 4 / 3; border-radius: var(--radius-sm); overflow: hidden; background: #0d1410; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner-frame { position: absolute; inset: 22% 12%; border-radius: 14px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); border: 2px solid rgba(255, 255, 255, .85); pointer-events: none; opacity: 0; transition: opacity .2s; }
.scanner-frame span { position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: #ff5252; box-shadow: 0 0 10px #ff5252; animation: scanline 1.8s ease-in-out infinite; }
@keyframes scanline { 0%, 100% { transform: translateY(-30px); } 50% { transform: translateY(30px); } }
.scanner.running .scanner-frame, .scanner-card .scanner-frame { opacity: 1; }
.scanner-idle { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; color: #e5eee8; text-align: center; padding: 1rem;
  background: radial-gradient(circle at 50% 30%, rgba(46, 125, 50, .45), transparent 70%), #0d1410; }
.scanner-idle > i { font-size: 3rem; color: #a5d6a7; }
.scanner-idle p { margin: 0; font-weight: 600; opacity: .9; }

/* Scheda prodotto */
.product-head { display: flex; gap: 1rem; margin-bottom: 1rem; }
.product-img { flex: 0 0 110px; height: 110px; border-radius: 14px; background: #fff; border: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; color: var(--muted); font-size: 2.2rem; }
.product-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.product-title { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; margin: 0 0 .15rem; }
.product-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.score { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem .15rem .4rem; border-radius: 8px; font-weight: 800; font-size: .9rem; color: #fff; background: #9aa5a0; line-height: 1.4; }
.score small { font-size: .62rem; font-weight: 700; text-transform: uppercase; opacity: .9; letter-spacing: .03em; }
.score-a { background: #038141; } .score-b { background: #85bb2f; } .score-c { background: #fecb02; color: #3b3000; } .score-d { background: #ee8100; } .score-e { background: #e63e11; }
.score-nova { background: var(--c-avviso); }
.nutri-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.nutri-grid div { background: var(--surface-2); border-radius: 10px; padding: .5rem .7rem; display: flex; flex-direction: column; }
.nutri-grid small { color: var(--muted); font-size: .75rem; font-weight: 600; }
.product details summary { cursor: pointer; }

/* Carrello */
.cart-list { display: grid; gap: .6rem; }
.cart-item { display: flex; gap: .85rem; padding: .8rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.cart-item.recalled { border-color: var(--c-micro); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c-micro) 25%, transparent); }
.cart-img { flex: 0 0 64px; height: 64px; border-radius: 12px; background: #fff; border: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; font-size: 1.8rem; text-decoration: none; }
.cart-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.cart-main { flex: 1; min-width: 0; }
.cart-name { font-weight: 700; line-height: 1.25; }
.cart-meta { font-size: .82rem; color: var(--muted); }
.cart-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .55rem; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.qty button { border: 0; background: var(--surface-2); color: var(--text); width: 30px; height: 30px; font-weight: 800; }
.qty span { min-width: 28px; text-align: center; font-weight: 700; font-size: .9rem; }
.cart-price { width: 90px; border-radius: 999px; }
.cart-store { width: auto; max-width: 150px; border-radius: 999px; }
.tag { display: inline-flex; align-items: center; gap: .25rem; font-size: .72rem; font-weight: 700; padding: .15rem .45rem; border-radius: 6px; background: var(--surface-2); }
.tag-danger { background: color-mix(in srgb, var(--c-micro) 14%, var(--surface)); color: var(--c-micro); }
.tag-warn { background: #fff4d6; color: #8a5a00; }
[data-bs-theme="dark"] .tag-warn { background: #3a2f12; color: #ffd54f; }

/* Analisi */
.rank-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .8rem; }
.rank-list li { display: flex; align-items: center; gap: .7rem; }
.rank { width: 24px; height: 24px; border-radius: 50%; background: var(--brand-100); color: var(--brand-700); font-weight: 800; font-size: .78rem; display: grid; place-items: center; flex-shrink: 0; }
.rank-emoji { font-size: 1.4rem; }
.rank-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .3rem; }
.rank-main b { font-size: .92rem; }
.rank-val { text-align: right; display: flex; flex-direction: column; line-height: 1.15; }
.rank-val small { color: var(--muted); font-size: .75rem; }
.donut-wrap { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.donut { width: 140px; height: 140px; border-radius: 50%; position: relative; flex-shrink: 0; background: var(--surface-2); }
.donut::after { content: ""; position: absolute; inset: 26%; border-radius: 50%; background: var(--surface); }
.donut-wrap .legend-list { flex: 1; min-width: 160px; margin: 0; }
.ring { --p: 0; width: 170px; height: 170px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--surface-2) 0); }
.ring span { width: 130px; height: 130px; border-radius: 50%; background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring b { font-size: 2.2rem; font-weight: 800; color: var(--brand); letter-spacing: -.03em; line-height: 1; }
.ring small { color: var(--muted); font-weight: 600; font-size: .8rem; }
.score-dist { display: grid; gap: .5rem; }
.score-row { display: grid; grid-template-columns: 34px 1fr 3rem; align-items: center; gap: .6rem; }
.score-row .score { justify-content: center; padding: .15rem 0; }
.score-row b { text-align: right; font-size: .9rem; }
.insights { display: grid; gap: .6rem; }
.insight { display: flex; gap: .8rem; align-items: center; padding: .7rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.insight b { display: block; }
.insight small { color: var(--muted); }

/* Liste impostazioni / programmi */
.list-group-app { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.program { display: flex; align-items: center; gap: .85rem; padding: .85rem 1rem; width: 100%; text-align: left; color: var(--text); text-decoration: none;
  background: transparent; border: 0; margin: 0; cursor: pointer; }
.program + .program { border-top: 1px solid var(--border); }
a.program:hover, button.program:hover { background: var(--surface-2); color: var(--text); }
.program-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.program-text small { color: var(--muted); font-size: .82rem; }
.status-pill { font-size: .72rem; font-weight: 800; padding: .25rem .6rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.st-nuova { background: #fff4d6; color: #8a5a00; } .st-inoltrata, .st-in_attesa { background: color-mix(in srgb, var(--sky) 14%, var(--surface)); color: var(--sky); }
.st-completata { background: var(--brand-100); color: var(--brand-700); } .st-respinta { background: color-mix(in srgb, var(--c-micro) 14%, var(--surface)); color: var(--c-micro); }

/* Moduli */
.form-control, .form-select { border-color: var(--border); background-color: var(--surface); color: var(--text); }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 15%, transparent); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: 1.4rem 1rem; text-align: center; cursor: pointer;
  border: 2px dashed var(--border); border-radius: var(--radius-sm); background: var(--surface-2); transition: border-color .15s, background .15s; }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone > i { font-size: 1.8rem; color: var(--brand); }
.dropzone small { color: var(--muted); }
.dropzone.drag, .dropzone.has-file { border-color: var(--brand); background: var(--brand-50); }
.done-icon { width: 76px; height: 76px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 2.2rem; background: var(--brand-100); color: var(--brand); }
.timeline { list-style: none; padding: 0; margin: 1.25rem auto; max-width: 360px; display: grid; gap: .7rem; }
.timeline li { position: relative; padding-left: 2rem; color: var(--muted); }
.timeline li::before { content: ""; position: absolute; left: 0; top: .15rem; width: 1.2rem; height: 1.2rem; border-radius: 50%; border: 2px solid var(--border); background: var(--surface); }
.timeline li.done { color: var(--text); }
.timeline li.done::before { background: var(--brand); border-color: var(--brand); }

@media (max-width: 575.98px) {
  .action-icon { width: 40px; height: 40px; font-size: 1.15rem; }
  .product-img { flex-basis: 84px; height: 84px; }
  .nutri-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* =========================================================
   Struttura app: barra laterale (desktop) e tab bar (mobile)
   ========================================================= */
:root { --sidebar-w: 248px; }
.sidebar { display: none; }
.shell { display: flex; flex-direction: column; flex: 1 0 auto; min-width: 0; }
.kpi-unit { font-size: .95rem; font-weight: 700; color: var(--muted); letter-spacing: 0; }
a.kpi { text-decoration: none; transition: background .15s, transform .15s; }
a.kpi:not(.kpi-main):hover { background: rgba(255, 255, 255, .2); color: #fff; }
.head-actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; padding-top: .35rem; }
.icon-btn { position: relative; }
.icon-badge { position: absolute; top: -4px; right: -4px; background: var(--brand); color: #fff; font-size: .62rem; font-weight: 800; border-radius: 99px; padding: 0 .32rem; line-height: 1.5; }
.nav-icon { position: relative; display: inline-grid; place-items: center; }
.nav-badge { position: absolute; top: -5px; right: -10px; background: var(--accent); color: #1a1a1a; font-size: .6rem; font-weight: 800; border-radius: 99px; padding: 0 .3rem; line-height: 1.45; }
.alert-dot { position: absolute; top: -3px; left: -5px; width: 10px; height: 10px; border-radius: 50%; background: var(--c-micro); border: 2px solid var(--surface); }
.btn-light.text-brand:hover { color: var(--brand-700) !important; }

/* tab bar mobile */
.tabbar .tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem; text-decoration: none; color: var(--muted); font-size: .68rem; font-weight: 700; }
.tabbar .tab .nav-icon { font-size: 1.3rem; width: 52px; height: 30px; border-radius: 99px; transition: background .15s; }
.tabbar .tab.active { color: var(--brand-700); }
.tabbar .tab.active .nav-icon { background: var(--brand-100); }
[data-bs-theme="dark"] .tabbar .tab.active { color: #a5d6a7; }
.tabbar .nav-badge { right: 4px; top: -3px; }
.tabbar .alert-dot { left: 8px; }

@media (min-width: 992px) {
  .tabbar { display: none; }
  body { display: block; }
  .shell { margin-left: var(--sidebar-w); min-height: 100vh; }
  .sidebar {
    display: flex; flex-direction: column; gap: 1.25rem; position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 1040;
    padding: 1.25rem .85rem 1rem; background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto;
  }
  .sidebar .brand { padding: .25rem .6rem .75rem; }
  .side-nav, .side-bottom { display: flex; flex-direction: column; gap: .2rem; }
  .side-bottom { margin-top: auto; padding-top: .75rem; border-top: 1px solid var(--border); }
  .side-link {
    display: flex; align-items: center; gap: .8rem; width: 100%; padding: .62rem .8rem; border: 0; border-radius: 12px; background: transparent;
    color: var(--muted); font-weight: 600; font-size: .95rem; text-decoration: none; text-align: left; transition: background .15s, color .15s;
  }
  .side-link .nav-icon { font-size: 1.15rem; width: 22px; }
  .side-link:hover { background: var(--surface-2); color: var(--text); }
  .side-link.active { background: var(--brand-100); color: var(--brand-700); }
  [data-bs-theme="dark"] .side-link.active { color: #a5d6a7; }
  .side-link .nav-badge { position: static; margin-left: .35rem; order: 3; }
  .side-link .nav-icon .nav-badge { position: absolute; }

  .app-header { background: color-mix(in srgb, var(--bg) 80%, transparent); border-bottom-color: transparent; }
  .top-search { position: relative; align-items: center; flex: 1; max-width: 520px; }
  .top-search i { position: absolute; left: 1rem; color: var(--muted); }
  .top-search input {
    width: 100%; height: 44px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
    border-radius: 999px; padding: 0 1rem 0 2.6rem; font-size: .93rem; box-shadow: var(--shadow-sm);
  }
  .top-search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 15%, transparent); }

  .container-xl { max-width: 1240px; padding-left: 2rem; padding-right: 2rem; }
  .hero { margin: .25rem 2rem 0; border-radius: 28px; padding: 3rem .5rem 3.25rem; }
  .app-footer { margin-top: 3rem; background: transparent; }
  .page-head { padding-top: 1.5rem; }
  .page-home .top-search { visibility: hidden; }
}
@media (min-width: 1400px) {
  .hero { margin-left: auto; margin-right: auto; max-width: 1176px; }
}

/* =========================================================
   App shell v3: barra dell'app, schermate, liste, pannelli
   ========================================================= */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .18s; }
body { -webkit-tap-highlight-color: transparent; }
body.scan-open { overflow: hidden; }

/* barra superiore */
.appbar {
  position: sticky; top: 0; z-index: 1030; display: flex; align-items: center; gap: .5rem;
  min-height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 1rem 0;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px);
}
.appbar-title { font-size: 1.35rem; font-weight: 800; letter-spacing: -.025em; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.is-sub .appbar-title { font-size: 1.08rem; font-weight: 700; text-align: center; }
.is-sub .appbar-actions:empty::before { content: ""; display: block; width: 40px; }
.appbar-actions { display: flex; align-items: center; gap: .35rem; }
.appbar-btn { width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; border: 0; background: transparent; color: var(--text); font-size: 1.2rem; text-decoration: none; }
.appbar-btn:hover, .appbar-btn:active { background: var(--surface-2); color: var(--text); }
.appbar-logo img { border-radius: 50%; display: block; }
.app-main { padding-bottom: 1.5rem; }
.screen { padding-top: .25rem; }
.lead-sm { color: var(--muted); font-size: .93rem; margin-bottom: 1rem; }
.list-title { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.6rem .25rem .5rem; }

/* tab bar con pulsante Scan */
.tabbar { align-items: end; }
.tabbar .tab { border: 0; background: transparent; padding: 0; height: var(--tabbar-h); }
.tabbar .tab-scan { color: var(--brand-700); }
.tabbar .tab-scan .nav-icon { width: 56px; height: 56px; margin-top: -24px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 1.5rem;
  box-shadow: 0 10px 22px -8px rgba(27, 94, 32, .7); border: 4px solid var(--bg); }
.tabbar .tab-scan .nav-label { margin-top: -2px; }

/* ricerca e filtri */
.screen-sticky { position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 1020; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); padding-bottom: .1rem; }
.screen-sticky .chip-scroller { padding: .65rem 0 .55rem; }
.searchbar { position: relative; display: flex; align-items: center; }
.searchbar i { position: absolute; left: 1rem; color: var(--muted); }
.searchbar input { width: 100%; height: 46px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 0 1rem 0 2.6rem; font-size: 1rem; }
.searchbar input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 14%, transparent); }
.chip { box-shadow: none; }
.chip-brand { --chip: var(--brand); }
.list-count { color: var(--muted); font-size: .85rem; font-weight: 600; margin: .25rem .25rem .6rem; }

/* liste */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list > * + * { border-top: 1px solid var(--border); }
.list-empty { padding: 1.1rem 1.15rem; color: var(--muted); font-size: .92rem; }
.load-more-wrap { padding: .9rem; text-align: center; }
.ritem { display: flex; align-items: center; gap: .85rem; padding: .8rem 1rem; color: var(--text); text-decoration: none; transition: background .12s; }
.ritem:hover, .ritem:active { background: var(--surface-2); color: var(--text); }
.ritem-media { flex: 0 0 52px; height: 52px; border-radius: 12px; overflow: hidden; display: grid; place-items: center; font-size: 1.35rem;
  color: var(--cat); background: color-mix(in srgb, var(--cat) 11%, var(--surface-2)); }
.ritem-media img { width: 100%; height: 100%; object-fit: cover; background: #fff; }
.ritem-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.ritem-title { font-weight: 700; font-size: .95rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ritem-meta { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ritem-cat { color: var(--cat); font-weight: 700; }
.ritem-why { font-size: .76rem; font-weight: 700; color: var(--brand-700); }
[data-bs-theme="dark"] .ritem-why { color: #a5d6a7; }
.ritem-flag { display: none; font-size: .74rem; font-weight: 700; color: #8a5a00; }
[data-bs-theme="dark"] .ritem-flag { color: #ffd54f; }
.ritem.in-pantry { box-shadow: inset 4px 0 0 var(--accent); }
.ritem.in-pantry .ritem-flag { display: block; }
.ritem-side { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; font-size: .75rem; color: var(--muted); font-weight: 600; white-space: nowrap; }

/* Per te */
.hello { margin: .25rem .25rem 1rem; }
.hello h2 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.03em; margin: 0; }
.hello p { color: var(--muted); margin: 0; }
.status-card { display: flex; align-items: center; gap: .9rem; padding: 1rem 1.1rem; border-radius: 20px; text-decoration: none; color: #fff;
  background: linear-gradient(135deg, var(--brand-700), var(--brand)); box-shadow: var(--shadow); }
.status-card:hover { color: #fff; }
.status-card.bad { background: linear-gradient(135deg, #b71c1c, #e53935); }
.status-card.idle { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.status-card.idle:hover { color: var(--text); }
.status-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 1.45rem; background: rgba(255, 255, 255, .18); flex-shrink: 0; }
.status-card.idle .status-icon { background: var(--brand-100); color: var(--brand); }
.status-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.status-text b { font-size: 1.08rem; }
.status-text small { opacity: .85; }
.block { margin-top: 1.6rem; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 .25rem .55rem; }
.block-head h3 { font-size: 1.05rem; font-weight: 800; margin: 0; }
.block-head a { font-size: .85rem; font-weight: 700; text-decoration: none; }

/* Spesa */
.summary-card { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.1rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none; margin-bottom: .75rem; }
.summary-card:hover { color: var(--text); border-color: color-mix(in srgb, var(--brand) 35%, var(--border)); }
.summary-main { display: flex; flex-direction: column; }
.summary-main small { color: var(--muted); font-weight: 600; font-size: .8rem; }
.summary-main b { font-size: 1.7rem; font-weight: 800; letter-spacing: -.03em; color: var(--brand); line-height: 1.1; }
.summary-stats { display: flex; gap: 1.1rem; margin-left: auto; }
.summary-stats span { display: flex; flex-direction: column; align-items: center; }
.summary-stats b { font-size: 1.05rem; }
.summary-stats small { color: var(--muted); font-size: .7rem; font-weight: 600; }
.summary-card > .bi-chevron-right { color: var(--muted); }
.source-card { display: flex; align-items: center; gap: .85rem; padding: .8rem 1rem; border-radius: var(--radius); background: var(--brand-50); color: var(--text);
  border: 1px dashed color-mix(in srgb, var(--brand) 35%, transparent); text-decoration: none; margin-bottom: 1.1rem; text-align: left; }
.source-card:hover { color: var(--text); background: var(--brand-100); }
.receipt { margin-bottom: 1rem; }
.receipt-head { display: flex; align-items: baseline; gap: .5rem; margin: 0 .25rem .45rem; font-size: .88rem; }
.receipt-head span { color: var(--muted); font-weight: 600; }
.pitem { display: flex; align-items: center; gap: .8rem; width: 100%; padding: .7rem 1rem; border: 0; background: transparent; color: var(--text); text-align: left; }
.pitem:hover, .pitem:active { background: var(--surface-2); }
.pitem.recalled { box-shadow: inset 4px 0 0 var(--c-micro); }
.pitem-img { flex: 0 0 44px; height: 44px; border-radius: 10px; background: #fff; border: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; font-size: 1.3rem; }
.pitem-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pitem-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pitem-name { font-weight: 700; font-size: .93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pitem-meta { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pitem-side { display: flex; align-items: center; gap: .55rem; }
.pitem-price { font-weight: 700; font-size: .88rem; white-space: nowrap; }
.score-dot { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; font-size: .72rem; font-weight: 800; color: #fff; }
.score-dot.score-c { color: #3b3000; }
.list-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem; margin-top: .5rem; }
.list-tools .btn { text-decoration: none; color: var(--muted); font-weight: 600; }

/* pannelli dal basso */
.sheet.offcanvas-bottom { height: auto; max-height: 90vh; border: 0; border-radius: 24px 24px 0 0; background: var(--surface); color: var(--text);
  padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -10px 40px rgba(0, 0, 0, .18); }
.sheet .offcanvas-body { padding: .5rem 1.15rem 1.25rem; overflow-y: auto; }
.sheet-handle { width: 42px; height: 5px; border-radius: 99px; background: var(--border); margin: .6rem auto .2rem; cursor: pointer; flex-shrink: 0; }
.sheet-title { font-size: 1.2rem; font-weight: 800; margin: .5rem 0 1rem; }
.sheet-sep { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .8rem; font-weight: 600; margin: .25rem 0 .9rem; }
.sheet-sep::before, .sheet-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.verdict { display: flex; gap: .8rem; align-items: center; padding: .85rem 1rem; border-radius: 16px; margin-bottom: .9rem; }
.verdict > i { font-size: 1.6rem; }
.verdict b { display: block; font-size: 1.02rem; }
.verdict small { display: block; opacity: .85; }
.verdict-ok { background: var(--brand-50); color: var(--brand-700); }
.verdict-bad { background: color-mix(in srgb, var(--c-micro) 12%, var(--surface)); color: #b71c1c; }
.verdict-warn { background: #fff4d6; color: #7a4f00; }
.verdict-wait { background: var(--surface-2); color: var(--muted); }
[data-bs-theme="dark"] .verdict-ok { color: #a5d6a7; }
[data-bs-theme="dark"] .verdict-bad { color: #ff8a80; }
[data-bs-theme="dark"] .verdict-warn { background: #3a2f12; color: #ffd54f; }
.product-head { margin-bottom: .9rem; }
.product-img { flex-basis: 84px; height: 84px; }
.product-img span { font-size: 2rem; }
.product-title { font-size: 1.15rem; }
.product-more { margin-top: 1.1rem; }
.product-more summary { font-weight: 700; cursor: pointer; }
.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.kv span { color: var(--muted); }
.kv b { text-align: right; font-weight: 600; }
.item-edit { display: grid; grid-template-columns: auto 1fr; gap: .5rem; }
.item-edit .qty { justify-content: space-between; }
.item-edit .qty button { width: 40px; height: 40px; }

/* scanner a tutto schermo */
.scan-overlay { position: fixed; inset: 0; z-index: 1060; background: #000; color: #fff; display: flex; flex-direction: column; }
.scan-overlay[hidden] { display: none; }
.scan-top { position: absolute; top: 0; left: 0; right: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: calc(env(safe-area-inset-top) + .75rem) 1rem .75rem; }
.scan-title { font-weight: 700; }
.scan-round { width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .16); color: #fff; font-size: 1.2rem; display: grid; place-items: center; backdrop-filter: blur(8px); }
.scan-round[hidden] { visibility: hidden; display: grid; }
.scan-view { position: relative; flex: 1; overflow: hidden; }
.scan-view video { width: 100%; height: 100%; object-fit: cover; }
.scan-view .scanner-frame { opacity: 1; inset: 32% 10%; }
.scan-hint { position: absolute; left: 0; right: 0; bottom: 1rem; text-align: center; margin: 0; font-weight: 600; text-shadow: 0 1px 4px rgba(0, 0, 0, .6); padding: 0 1rem; }
.scan-bottom { padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); background: #0d1410; }
.scan-manual { display: flex; gap: .5rem; }
.scan-manual input { flex: 1; min-width: 0; height: 48px; border-radius: 999px; border: 0; background: rgba(255, 255, 255, .12); color: #fff; padding: 0 1.1rem; font-size: 1rem; }
.scan-manual input::placeholder { color: rgba(255, 255, 255, .6); }
.scan-manual input:focus { outline: 2px solid var(--accent); }
.scan-recent { display: flex; gap: .4rem; overflow-x: auto; margin-top: .7rem; align-items: center; scrollbar-width: none; }
.scan-recent small { opacity: .6; font-weight: 600; margin-right: .2rem; }
.scan-recent button { flex-shrink: 0; border: 0; border-radius: 999px; background: rgba(255, 255, 255, .1); color: #fff; padding: .35rem .8rem; font-size: .8rem; font-weight: 600; }

/* configurazione iniziale */
.onboarding { position: fixed; inset: 0; z-index: 1070; background: var(--bg); display: grid; place-items: center; padding: 1rem; overflow-y: auto; }
.onboarding[hidden] { display: none; }
.onb-card { width: 100%; max-width: 460px; text-align: center; padding: calc(env(safe-area-inset-top) + 1rem) .5rem 1rem; }
.onb-card h2 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.03em; }
.onb-card h3 { font-size: 1rem; font-weight: 800; margin: 1.4rem 0 .8rem; }
.onb-card p { color: var(--muted); }
.onb-icon { width: 72px; height: 72px; border-radius: 22px; display: inline-grid; place-items: center; font-size: 2rem; background: var(--brand-100); color: var(--brand); margin-bottom: 1rem; }
.onb-dots { display: flex; justify-content: center; gap: .4rem; margin-bottom: 1.5rem; }
.onb-dots span { width: 26px; height: 5px; border-radius: 99px; background: var(--border); }
.onb-dots span.on { background: var(--brand); }
.onb-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 2rem; }

/* profilo */
.profile-head { display: flex; align-items: center; gap: .9rem; padding: .5rem .25rem 0; }
.profile-head b { display: block; font-size: 1.1rem; }
.profile-head small { color: var(--muted); }
.avatar { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; background: var(--brand-100); color: var(--brand); flex-shrink: 0; }
.program.sub { padding-left: 4.4rem; cursor: default; }
.follow-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem; }
.follow-form { display: flex; gap: .5rem; }
.follow-form input { flex: 1; min-width: 0; border: 0; background: var(--surface-2); border-radius: 999px; padding: .5rem 1rem; color: var(--text); }
.follow-form input:focus { outline: 2px solid var(--brand); }
.follow-box .watch-chips:not(:empty) { margin-top: .7rem; }

/* dettaglio richiamo dentro la shell */
.detail { padding-top: .5rem; }

/* desktop */
@media (min-width: 992px) {
  .appbar { padding: 0 2rem; min-height: 64px; }
  .appbar-title { font-size: 1.6rem; }
  .is-sub .appbar-title { text-align: left; font-size: 1.25rem; }
  .screen-sticky { top: 64px; }
  .sidebar { gap: 1rem; }
  .sidebar .btn-brand { margin: .25rem 0 .5rem; }
  .container-xl { max-width: 1080px; }
  .app-main { padding-bottom: 3rem; }
  .sheet.offcanvas-bottom { left: 50%; right: auto; width: 560px; transform: translate(-50%, 100%); border-radius: 24px 24px 0 0; }
  .sheet.offcanvas-bottom.show:not(.hiding), .sheet.offcanvas-bottom.showing { transform: translate(-50%, 0); }
  .scan-overlay { inset: 5vh auto 5vh 50%; width: 480px; transform: translateX(-50%); border-radius: 28px; overflow: hidden; box-shadow: 0 30px 80px rgba(0, 0, 0, .45); }
  body.scan-open::after { content: ""; position: fixed; inset: 0; z-index: 1055; background: rgba(0, 0, 0, .5); }
  .onboarding { background: rgba(10, 20, 14, .55); }
  .onb-card { background: var(--bg); border-radius: 28px; padding: 2rem; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
  .hello h2 { font-size: 2rem; }
}
@media (max-width: 991.98px) {
  .container-xl { --bs-gutter-x: 1.5rem; }
}
.ritem-side .new-badge { background: transparent; color: var(--accent-600); padding: 0; font-size: .68rem; letter-spacing: .03em; }
.ritem-side .new-badge::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: .3rem; vertical-align: 1px; }
@media (min-width: 992px) {
  .appbar { padding-inline: max(2rem, calc((100% - 1080px) / 2 + 2rem)); }
  .page-home .appbar-title { visibility: hidden; }
  .page-home .appbar { min-height: 24px; }
}

/* =========================================================
   Spesa GDO, tessere e assistente AI
   ========================================================= */
.cards-row { display: flex; gap: .6rem; overflow-x: auto; scrollbar-width: none; margin-bottom: 1.1rem; padding-bottom: 2px; }
.cards-row::-webkit-scrollbar { display: none; }
.loyalty-card { flex: 0 0 auto; display: flex; align-items: center; gap: .7rem; min-width: 210px; padding: .8rem 1rem; border-radius: 16px; text-decoration: none; color: #fff;
  background: linear-gradient(135deg, var(--brand-700), var(--brand) 60%, #5aa53f); box-shadow: var(--shadow-sm); }
.loyalty-card:hover { color: #fff; }
.loyalty-card > i { font-size: 1.5rem; opacity: .9; }
.loyalty-card b { display: block; }
.loyalty-card small { opacity: .85; font-size: .76rem; }
.loyalty-card.add { min-width: 0; padding: .8rem 1.1rem; background: var(--surface); color: var(--brand); border: 1px dashed color-mix(in srgb, var(--brand) 40%, transparent); }
.receipt-info { display: flex; gap: .8rem; align-items: flex-start; padding: .85rem 1rem; border-radius: 14px; background: var(--surface-2); }
.receipt-info > i { font-size: 1.4rem; color: var(--brand); }
.receipt-info b, .receipt-info small { display: block; }
.pitem-price small { color: var(--muted); font-weight: 600; font-size: .72rem; }
.month-chart { display: grid; grid-template-columns: repeat(auto-fit, minmax(38px, 1fr)); gap: .35rem; align-items: end; height: 190px; }
.month-bar { display: flex; flex-direction: column; align-items: center; height: 100%; gap: .25rem; min-width: 0; }
.month-col { flex: 1; width: 100%; max-width: 34px; display: flex; align-items: flex-end; }
.month-col span { display: block; width: 100%; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, var(--lime), var(--brand)); }
.month-val { font-size: .62rem; color: var(--muted); font-weight: 700; white-space: nowrap; }
.month-lbl { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: capitalize; }

.chat-fab { position: fixed; right: 1rem; bottom: calc(var(--tabbar-h) + 1rem + env(safe-area-inset-bottom)); z-index: 1035; width: 56px; height: 56px; border-radius: 50%; border: 0;
  display: grid; place-items: center; font-size: 1.55rem; color: #fff; background: linear-gradient(135deg, var(--brand-700), var(--brand) 60%, #5aa53f); box-shadow: 0 12px 28px -10px rgba(27, 94, 32, .7);
  transition: transform .15s; }
.chat-fab:hover { transform: scale(1.06); }
body.scan-open .chat-fab, .is-sub .chat-fab { display: none; }
.chat-sheet.offcanvas-bottom { height: 86vh; max-height: 86vh; display: flex; flex-direction: column; }
.chat-head { display: flex; align-items: center; gap: .75rem; padding: .25rem 1rem .75rem; border-bottom: 1px solid var(--border); }
.chat-head b { display: block; }
.chat-head small { color: var(--muted); }
.chat-avatar { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-size: 1.3rem; color: #fff; background: linear-gradient(135deg, var(--brand-700), var(--brand)); flex-shrink: 0; }
.chat-body { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .6rem; }
.chat-msg { max-width: 88%; padding: .65rem .9rem; border-radius: 18px; font-size: .94rem; line-height: 1.45; }
.chat-msg p { margin: 0; }
.chat-msg p + p { margin-top: .5rem; }
.chat-msg ul { margin: .35rem 0; padding-left: 1.1rem; }
.chat-msg.bot { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 6px; }
.chat-msg.me { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 6px; }
.chat-msg.typing { display: flex; gap: .3rem; padding: .85rem 1rem; }
.chat-msg.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: dot 1.2s infinite ease-in-out; }
.chat-msg.typing span:nth-child(2) { animation-delay: .15s; } .chat-msg.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.chat-suggest { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .25rem; }
.chat-suggest[hidden] { display: none; }
.chat-suggest button { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: .4rem .8rem; font-size: .82rem; font-weight: 600; text-align: left; }
.chat-suggest button:hover { border-color: var(--brand); color: var(--brand-700); }
.chat-input { display: flex; gap: .5rem; align-items: flex-end; padding: .75rem 1rem .25rem; border-top: 1px solid var(--border); }
.chat-input textarea { flex: 1; resize: none; border: 1px solid var(--border); border-radius: 20px; padding: .6rem 1rem; background: var(--surface-2); color: var(--text); font-size: .95rem; max-height: 120px; }
.chat-input textarea:focus { outline: none; border-color: var(--brand); background: var(--surface); }
.chat-input .btn { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; flex-shrink: 0; }
.chat-note { font-size: .7rem; color: var(--muted); text-align: center; margin: .25rem 0 .5rem; }
@media (min-width: 992px) {
  .chat-fab { bottom: 1.5rem; right: 1.5rem; }
  .chat-sheet.offcanvas-bottom { height: 78vh; }
}
a.stat { text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; }
a.stat:hover { color: inherit; border-color: color-mix(in srgb, var(--brand) 35%, var(--border)); transform: translateY(-2px); }
#homeSpesa .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 992px) { #homeSpesa .kpi-row { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.cta-panel { display: grid; grid-template-columns: auto 1fr; gap: .9rem 1rem; align-items: center; }
.cta-panel b { display: block; font-size: 1.05rem; }
.cta-panel small { color: var(--muted); }
.cta-panel .btn, .cta-panel > a.small { grid-column: 1 / -1; }
.home .block[hidden], #statusCard[hidden] { display: none !important; }
