:root {
  --bg: #f6f2ea;
  --surface: #fffdf9;
  --surface-2: #f1ebdf;
  --surface-3: #e9e1d2;
  --ink: #1d2721;
  --muted: #6a7268;
  --line: #e3dbcb;
  --primary: #2b6449;
  --primary-2: #3c805e;
  --primary-ink: #ffffff;
  --primary-soft: #e0eee5;
  --accent: #d9672b;
  --accent-soft: #fce8d8;
  --danger: #b5412f;
  --hero-a: #1f4d37;
  --hero-b: #2b6449;
  --hero-c: #3f8460;
  --shadow-sm: 0 1px 2px rgba(45, 35, 15, .06), 0 2px 8px rgba(45, 35, 15, .05);
  --shadow: 0 1px 2px rgba(45, 35, 15, .06), 0 10px 30px rgba(45, 35, 15, .10);
  --radius: 18px;
  --font: "Open Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Open Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121814;
    --surface: #1a221d;
    --surface-2: #222c26;
    --surface-3: #2b3730;
    --ink: #ecf1ea;
    --muted: #9ba79d;
    --line: #2d3a32;
    --primary: #5fb88a;
    --primary-2: #77c99d;
    --primary-ink: #0d1a13;
    --primary-soft: #1f3a2b;
    --accent: #f29a5c;
    --accent-soft: #3b2818;
    --danger: #ef7f6c;
    --hero-a: #0f2a1d;
    --hero-b: #17402c;
    --hero-c: #23573c;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
mark { background: var(--accent-soft); color: inherit; border-radius: 4px; padding: 0 2px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; }

/* ---------- Bottoni ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 12px;
  padding: 10px 16px; font-weight: 600; line-height: 1.2;
  transition: background .15s, transform .1s, box-shadow .15s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn-primary { background: var(--primary); color: var(--primary-ink); box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 30%, transparent); }
.btn-primary:hover:not(:disabled) { background: var(--primary-2); }
.btn-light { background: rgba(255, 255, 255, .95); color: #1f4d37; box-shadow: 0 6px 20px rgba(0, 0, 0, .15); }
.btn-light:hover { background: #fff; }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-soft:hover { background: color-mix(in srgb, var(--primary-soft) 80%, var(--primary) 20%); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.link { background: none; border: 0; padding: 0; color: var(--muted); font-size: .85rem; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--danger); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; border: 0;
  display: grid; place-items: center; background: var(--surface-2); color: var(--muted);
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }

/* ---------- Header ---------- */
.hero {
  position: relative;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(900px 300px at 85% -10%, rgba(246, 180, 106, .35), transparent 60%),
    radial-gradient(600px 260px at 0% 110%, rgba(255, 255, 255, .10), transparent 60%),
    linear-gradient(135deg, var(--hero-a), var(--hero-b) 55%, var(--hero-c));
  padding: 22px 16px 64px;
}
.hero::after {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .09) 1.2px, transparent 1.3px);
  background-size: 22px 22px;
  mask-image: linear-gradient(to bottom, #000 0%, transparent 85%);
  pointer-events: none;
}
.hero-inner { position: relative; z-index: 1; max-width: 1280px; margin: 0 auto; }
.topline { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 14px; color: inherit; text-decoration: none; }
.brand img { border-radius: 16px; box-shadow: 0 8px 22px rgba(0, 0, 0, .25); }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 1.9rem; letter-spacing: .02em; }
.brand-tag { font-size: .85rem; opacity: .82; margin-top: 4px; }

.searchbox {
  margin: 30px auto 0; max-width: 780px;
  display: flex; align-items: center; gap: 12px;
  background: #fff; color: #1d2721;
  border-radius: 18px; padding: 0 16px 0 20px; height: 62px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .22);
}
.searchbox svg { width: 22px; height: 22px; color: #3c805e; }
.searchbox input {
  flex: 1; min-width: 0; border: 0; outline: none; background: transparent;
  font-size: 1.08rem; height: 100%; color: #1d2721;
}
.searchbox input::placeholder { color: #8b9289; }
.searchbox input::-webkit-search-cancel-button { cursor: pointer; }
.searchbox kbd {
  font: 600 .8rem var(--font); color: #6a7268; border: 1px solid #e3dbcb;
  border-bottom-width: 2px; border-radius: 7px; padding: 2px 8px;
}

.filters { max-width: 780px; margin: 16px auto 0; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.seg { display: inline-flex; padding: 4px; border-radius: 14px; background: rgba(255, 255, 255, .14); gap: 2px; }
.seg button {
  border: 0; background: transparent; color: rgba(255, 255, 255, .85);
  padding: 7px 14px; border-radius: 10px; font-weight: 600; font-size: .9rem;
  display: inline-flex; align-items: center; gap: 8px;
}
.seg button.on { background: #fff; color: #1f4d37; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }
.cat-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid rgba(255, 255, 255, .28); background: transparent; color: #fff;
  border-radius: 999px; padding: 5px 12px; font-size: .85rem; font-weight: 500;
}
.chip:hover { background: rgba(255, 255, 255, .12); }
.chip.on { background: #f6b46a; border-color: #f6b46a; color: #3b2112; }
.chip .n { opacity: .65; margin-left: 4px; font-size: .78rem; }

/* ---------- Layout ---------- */
.layout {
  position: relative; z-index: 2;
  width: 100%; max-width: 1280px; margin: -34px auto 0; padding: 0 16px 40px;
  display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start;
  flex: 1;
}
.catalog {
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px;
  padding: 20px; box-shadow: var(--shadow); min-height: 320px;
}
.catalog-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.catalog-head h2 { font-family: var(--display); font-weight: 400; font-size: 1.4rem; margin: 0; }
.count { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.hint {
  margin: 0 0 14px; padding: 10px 14px; border-radius: 12px;
  background: var(--accent-soft); color: var(--ink); font-size: .9rem;
}

/* ---------- Schede prodotto ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 16px; }
.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; text-align: left; padding: 0;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s, border-color .15s;
  animation: rise .25s ease both;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary), var(--shadow); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.card-img { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.ph {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-family: var(--display); font-weight: 700; font-size: 3rem;
}
.badge {
  position: absolute; left: 10px; top: 10px;
  background: rgba(255, 255, 255, .9); color: #1d2721; backdrop-filter: blur(6px);
  font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px;
}
.badge.loose { background: rgba(252, 232, 216, .95); color: #8a3c12; }
.card-edit {
  position: absolute; right: 10px; top: 10px;
  width: 34px; height: 34px; border-radius: 11px; border: 0;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .92); color: #1d2721; box-shadow: var(--shadow-sm);
  opacity: 0; transition: opacity .15s;
}
.card-edit svg { width: 17px; height: 17px; }
.card:hover .card-edit, .card:focus-within .card-edit { opacity: 1; }
@media (hover: none) { .card-edit { opacity: 1; } }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-meta { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card h3 { margin: 0; font-size: 1.02rem; font-weight: 700; line-height: 1.3; }
.card-carbo { margin-top: 4px; display: flex; align-items: baseline; gap: 5px; color: var(--muted); font-size: .85rem; }
.card-carbo strong { font-family: var(--display); font-size: 1.45rem; color: var(--accent); font-weight: 700; }
.card-measures { display: flex; flex-wrap: wrap; gap: 5px; margin-top: auto; padding-top: 8px; }
.mchip { font-size: .75rem; background: var(--surface-2); border-radius: 8px; padding: 3px 8px; color: var(--ink); }
.mchip b { color: var(--accent); font-weight: 700; }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty .art { width: 96px; height: 96px; margin: 0 auto 12px; border-radius: 28px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.empty .art svg { width: 48px; height: 48px; stroke-width: 1.6; }
.empty h3 { color: var(--ink); font-family: var(--display); font-weight: 400; font-size: 1.35rem; margin: 0 0 6px; }
.empty p { margin: 0 0 18px; }

/* ---------- Calcolatrice ---------- */
.calc {
  position: sticky; top: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px;
  box-shadow: var(--shadow); overflow: hidden;
}
.calc-handle {
  width: 100%; border: 0; background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; gap: 10px; padding: 14px 18px; cursor: default;
}
.calc-title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1rem; }
.calc-peek { margin-left: auto; font-weight: 700; color: var(--accent); display: none; }
.calc-handle .chev { display: none; transition: transform .2s; }
.calc-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; }
.calc-body > label, .picker label { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.picker { position: relative; display: flex; flex-direction: column; gap: 6px; }
.picker input, .qty input, .f input, .f textarea, .ref-row input, .ref-row select, .measure input {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.picker input:focus, .qty input:focus, .f input:focus, .f textarea:focus, .ref-row input:focus, .ref-row select:focus, .measure input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.suggest {
  position: absolute; left: 0; right: 0; top: 100%; margin: 6px 0 0; padding: 6px; list-style: none; z-index: 20;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  max-height: 320px; overflow: auto;
}
.suggest li { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; cursor: pointer; }
.suggest li.active, .suggest li:hover { background: var(--surface-2); }
.suggest li.none { color: var(--muted); cursor: default; }
.suggest li span { display: flex; flex-direction: column; min-width: 0; }
.suggest li b { font-weight: 600; }
.suggest small { color: var(--muted); font-size: .78rem; }

.thumb { width: 40px; height: 40px; border-radius: 10px; overflow: hidden; flex: none; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .ph { font-size: 1.1rem; }
.thumb.lg { width: 56px; height: 56px; border-radius: 14px; }
.thumb.lg .ph { font-size: 1.5rem; }

.calc-product {
  display: flex; align-items: center; gap: 12px; padding: 10px; margin: 2px 0 6px;
  border-radius: 16px; background: var(--surface-2); min-height: 76px;
}
.calc-product .info { min-width: 0; flex: 1; }
.calc-product .name { font-weight: 700; line-height: 1.25; }
.calc-product .meta { font-size: .8rem; color: var(--muted); }
.calc-product .per { font-size: .82rem; margin-top: 2px; }
.calc-product .per b { color: var(--accent); }
.calc-product.empty-sel { color: var(--muted); font-size: .9rem; justify-content: center; text-align: center; padding: 14px; }
.calc-product .icon-btn { width: 30px; height: 30px; border-radius: 9px; background: transparent; }
.calc-product .icon-btn svg { width: 16px; height: 16px; }

.qty { display: grid; grid-template-columns: 48px 1fr 48px; gap: 8px; }
.qty button {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px;
  font-size: 1.4rem; font-weight: 600; line-height: 1;
}
.qty button:hover { background: var(--surface-3); }
.qty input { text-align: center; font-size: 1.35rem; font-weight: 700; padding: 8px; }
.units { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.unit {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 6px 12px; font-size: .84rem; font-weight: 600; color: var(--ink);
}
.unit small { color: var(--muted); font-weight: 500; margin-left: 3px; }
.unit:hover { border-color: var(--primary); }
.unit.on { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.unit.on small { color: inherit; opacity: .8; }

.result {
  margin: 10px 0 6px; padding: 18px 12px 14px; border-radius: 18px; text-align: center;
  background: linear-gradient(160deg, var(--accent-soft), color-mix(in srgb, var(--accent-soft) 40%, var(--surface)));
}
.result-num { font-family: var(--display); font-weight: 600; color: var(--accent); line-height: 1; }
.result-num span { font-size: 3.4rem; letter-spacing: -.01em; }
.result-num small { font-size: 1.4rem; margin-left: 4px; font-weight: 400; }
.result-label { font-weight: 600; margin-top: 2px; }
.result-equiv { font-size: .84rem; color: var(--muted); min-height: 1.3em; margin-top: 2px; }
.result.bump .result-num { animation: bump .25s ease; }
@keyframes bump { 50% { transform: scale(1.06); } }

.meal { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 12px; }
.meal-head { display: flex; align-items: center; justify-content: space-between; }
.meal-head h3 { margin: 0; font-size: .95rem; }
.meal ul { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.meal li { display: flex; align-items: center; gap: 8px; font-size: .88rem; padding: 6px 8px; border-radius: 10px; background: var(--surface-2); }
.meal li .what { flex: 1; min-width: 0; }
.meal li .what small { display: block; color: var(--muted); font-size: .76rem; }
.meal li b { color: var(--accent); white-space: nowrap; }
.meal li button { border: 0; background: none; color: var(--muted); padding: 2px; display: grid; }
.meal li button:hover { color: var(--danger); }
.meal li button svg { width: 15px; height: 15px; }
.meal-total { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; padding: 4px 8px 0; }
.meal-total strong { font-family: var(--display); font-size: 1.5rem; color: var(--accent); }

/* ---------- Footer ---------- */
.foot {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--muted); font-size: .85rem; padding: 8px 16px 28px; text-align: center;
}
.foot img { border-radius: 6px; }

/* ---------- Finestra prodotto ---------- */
.dlg {
  width: min(760px, calc(100vw - 24px)); max-height: min(92vh, 980px);
  padding: 0; border: 0; border-radius: 24px;
  background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
}
.dlg::backdrop { background: rgba(15, 22, 17, .5); backdrop-filter: blur(4px); }
.dlg[open] { animation: pop .2s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.dlg form { display: flex; flex-direction: column; max-height: inherit; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 10px; }
.dlg-head h2 { margin: 0; font-family: var(--display); font-weight: 300; font-size: 1.6rem; }
.dlg-body { padding: 8px 22px 16px; overflow: auto; display: flex; flex-direction: column; gap: 16px; }
.dlg-foot { display: flex; align-items: center; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface); }
.spacer { flex: 1; }

.seg-wide { background: var(--surface-2); display: grid; grid-template-columns: 1fr 1fr; }
.seg-wide button { color: var(--muted); justify-content: center; padding: 10px; font-size: .95rem; }
.seg-wide button.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

.form-top { display: grid; grid-template-columns: 170px 1fr; gap: 18px; }
.photo {
  position: relative; aspect-ratio: 1; border-radius: 18px; overflow: hidden;
  border: 2px dashed var(--line); background: var(--surface-2);
  display: grid; place-items: center; transition: border-color .15s;
}
.photo:hover, .photo.drag { border-color: var(--primary); }
.photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); font-weight: 600; text-align: center; }
.photo-empty svg { width: 34px; height: 34px; color: var(--primary); stroke-width: 1.6; }
.photo-empty small { font-weight: 500; font-size: .78rem; }
.photo input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-remove {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); z-index: 2;
  border: 0; border-radius: 999px; padding: 5px 12px; font-size: .8rem; font-weight: 600;
  background: rgba(0, 0, 0, .65); color: #fff;
}
.fields { display: flex; flex-direction: column; gap: 10px; }
.f { display: flex; flex-direction: column; gap: 5px; }
.f > span { font-size: .8rem; font-weight: 700; color: var(--muted); }
.f em { color: var(--accent); font-style: normal; }
.f textarea { resize: vertical; }

.box { border: 1px solid var(--line); border-radius: 18px; padding: 12px 16px 16px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.box legend { font-weight: 700; padding: 0 6px; margin-left: -6px; }
.note { margin: 0; font-size: .84rem; color: var(--muted); }
.ref-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.ref-row input { width: 96px; text-align: center; font-weight: 700; }
.ref-row select { width: auto; }
.piece-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fractions { display: flex; flex-wrap: wrap; gap: 6px; }
.frac {
  min-width: 52px; border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  padding: 7px 10px; font-weight: 700;
}
.frac.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
#genMeasures { align-self: flex-start; }

.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.preset {
  border: 1px dashed var(--line); background: transparent; border-radius: 999px;
  padding: 5px 12px; font-size: .84rem; font-weight: 600; color: var(--primary);
}
.preset:hover { background: var(--primary-soft); border-style: solid; border-color: var(--primary); }
.measures { display: flex; flex-direction: column; gap: 8px; }
.measures:empty::before { content: "Nessuna misura: aggiungine una con i pulsanti qui sopra."; color: var(--muted); font-size: .85rem; }
.measure { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr) 36px; gap: 8px; align-items: end; }
.measure .f > span { font-size: .72rem; }
.measure .del { height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); display: grid; place-items: center; }
.measure .del:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.measure .del svg { width: 17px; height: 17px; }
.unit-in { position: relative; }
.unit-in input { padding-right: 34px; }
.unit-in i { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); font-size: .82rem; pointer-events: none; }
.form-error { margin: 0; padding: 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); font-weight: 600; font-size: .9rem; }

/* ---------- Glutine e confezione ---------- */
.gf {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; letter-spacing: .02em; padding: 4px 9px; white-space: nowrap;
}
.gf::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.gf.yes { background: #dff1e4; color: #1f6b43; }
.gf.no { background: #fbe1dc; color: #a33a26; }
.card-img .gf { position: absolute; left: 10px; bottom: 10px; box-shadow: var(--shadow-sm); }
.card-pack { font-size: .8rem; color: var(--muted); }
.chip-gf { border-color: rgba(167, 230, 189, .6); }
.chip-gf.on { background: #a7e6bd; border-color: #a7e6bd; color: #123d26; }

.gluten-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.gluten-row > span { font-size: .8rem; font-weight: 700; color: var(--muted); }
.seg-pick { background: var(--surface-2); }
.seg-pick button { color: var(--muted); font-size: .86rem; padding: 7px 12px; }
.seg-pick button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg-pick button.gf-yes.on { background: #dff1e4; color: #1f6b43; }
.seg-pick button.gf-no.on { background: #fbe1dc; color: #a33a26; }
.pack-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 10px; }

.measures-head { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; align-items: center; }
.measures-head span { padding-left: 4px; }

.qty-in { position: relative; display: block; }
.qty-in i { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); font-size: .9rem; font-weight: 600; pointer-events: none; }
.calc-body > label small { text-transform: none; letter-spacing: 0; font-weight: 500; }

/* ---------- Scheda prodotto ---------- */
.dlg-view { width: min(620px, calc(100vw - 24px)); }
.view { display: flex; flex-direction: column; max-height: inherit; }
.view-kicker { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.view-top { display: grid; grid-template-columns: 180px 1fr; gap: 18px; align-items: start; }
.view-photo { aspect-ratio: 1; border-radius: 18px; overflow: hidden; background: var(--surface-2); }
.view-photo img { width: 100%; height: 100%; object-fit: cover; }
.view-photo .ph { font-size: 4rem; }
.view-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.view-name { margin: 0; font-family: var(--display); font-weight: 400; font-size: 1.75rem; line-height: 1.2; }
.view-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.pill { display: inline-flex; align-items: center; border-radius: 999px; background: var(--surface-2); padding: 4px 10px; font-size: .78rem; font-weight: 600; }
.view-ref { margin-top: 8px; color: var(--muted); }
.view-ref b { font-family: var(--display); font-size: 1.6rem; color: var(--accent); }

.quick {
  border-radius: 18px; padding: 14px 16px;
  background: linear-gradient(160deg, var(--accent-soft), color-mix(in srgb, var(--accent-soft) 40%, var(--surface)));
}
.quick label { display: block; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 8px; }
.quick-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.quick-row .qty-in { width: 140px; }
.quick-row input {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  padding: 10px 40px 10px 12px; font-size: 1.3rem; font-weight: 700; outline: none;
}
.quick-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.quick-eq { font-size: 1.4rem; color: var(--muted); }
.quick-res { font-weight: 600; }
.quick-res b { font-family: var(--display); font-size: 2.2rem; font-weight: 600; color: var(--accent); }

.combo { width: 100%; border-collapse: separate; border-spacing: 0; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.combo th { text-align: left; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); padding: 10px 14px; }
.combo td { padding: 12px 14px; border-top: 1px solid var(--line); }
.combo th:last-child, .combo td:last-child { text-align: right; }
.combo td b { font-family: var(--display); font-size: 1.15rem; color: var(--accent); }
.combo tbody tr { cursor: pointer; transition: background .12s; }
.combo tbody tr:hover { background: var(--primary-soft); }
.combo tr.ref td:first-child { font-weight: 700; }
.combo .muted { color: var(--muted); }
.view-notes { margin: 0; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); white-space: pre-wrap; }

/* ---------- Accesso ---------- */
.login-page {
  background:
    radial-gradient(900px 400px at 85% -10%, rgba(246, 180, 106, .35), transparent 60%),
    linear-gradient(135deg, var(--hero-a), var(--hero-b) 55%, var(--hero-c));
}
.login { flex: 1; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(380px, 100%); background: var(--surface); border-radius: 26px; padding: 32px 26px 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .3); display: flex; flex-direction: column; gap: 14px; text-align: center;
}
.login-card img { margin: 0 auto; border-radius: 20px; box-shadow: 0 10px 26px rgba(217, 95, 42, .35); }
.login-card h1 { margin: 4px 0 0; font-family: var(--display); font-size: 2.2rem; line-height: 1; }
.login-tag { margin: 0 0 8px; color: var(--muted); }
.login-card .f { text-align: left; }
.login-card .f input { font-size: 1.05rem; padding: 12px 14px; }
.login-card .btn { padding: 13px; font-size: 1rem; }
.btn-logout { background: transparent; color: rgba(255, 255, 255, .85); border-color: rgba(255, 255, 255, .3); padding: 10px 12px; }
.btn-logout:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.top-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); z-index: 100;
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 14px;
  font-weight: 600; font-size: .92rem; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Telefono e tablet ---------- */
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding-bottom: 110px; }
  .calc {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 50;
    border-radius: 24px 24px 0 0; border-bottom: 0;
    max-height: 88vh; display: flex; flex-direction: column;
    transform: translateY(calc(100% - 62px - env(safe-area-inset-bottom)));
    transition: transform .28s cubic-bezier(.2, .8, .2, 1);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, .18);
  }
  .calc.open { transform: translateY(0); }
  .calc-handle { cursor: pointer; min-height: 62px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .calc.open .calc-handle { padding-bottom: 14px; }
  .calc-handle .chev { display: block; }
  .calc.open .chev { transform: rotate(180deg); }
  .calc-peek { display: block; }
  .calc-body { overflow: auto; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .toast { bottom: 90px; }
}

@media (max-width: 640px) {
  .hero { padding: 16px 16px 56px; }
  .brand img { width: 44px; height: 44px; border-radius: 13px; }
  .brand-name { font-size: 1.6rem; }
  .brand-tag { font-size: .78rem; }
  .btn-light span { display: none; }
  .btn-light { padding: 11px; border-radius: 14px; }
  .searchbox { margin-top: 20px; height: 54px; border-radius: 16px; }
  .searchbox input { font-size: 1rem; }
  .searchbox kbd { display: none; }
  .layout { padding: 0 12px 110px; }
  .catalog { padding: 14px; border-radius: 20px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card-body { padding: 10px 11px 12px; }
  .card h3 { font-size: .95rem; }
  .card-carbo strong { font-size: 1.25rem; }
  .dlg { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
  .dlg form { height: 100%; }
  .dlg-body { flex: 1; }
  .form-top { grid-template-columns: 1fr; }
  .photo { aspect-ratio: 16 / 10; }
  .piece-row { grid-template-columns: 1fr; }
  .measure { grid-template-columns: minmax(0, 1fr) 74px 74px 30px; gap: 6px; }
  .measure input { padding: 9px 8px; }
  .unit-in input { padding-right: 26px; }
  .unit-in i { right: 7px; }
  .pack-row { grid-template-columns: 1fr 1fr; }
  .view-top { grid-template-columns: 110px 1fr; gap: 14px; }
  .view-name { font-size: 1.35rem; }
  .combo th, .combo td { padding: 10px; }
  .dlg-view { height: auto; max-height: 94dvh; margin: auto 0 0; border-radius: 22px 22px 0 0; }
}
