/* =========================================================================
   CodiceABarre — foglio di stile
   Due mondi, un solo oggetto: il banco cassa (scuro, strumentale, con la
   riga rossa del laser) e lo scontrino appena stampato (carta calda, righe
   con leader a puntini, cifre da registratore di cassa).
   ========================================================================= */

@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url("../fonts/archivo-latin.woff2") format("woff2-variations"),
       url("../fonts/archivo-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+20AC, U+2122;
}
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url("../fonts/archivo-latin-ext.woff2") format("woff2-variations"),
       url("../fonts/archivo-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Martian Mono";
  font-style: normal;
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  font-display: swap;
  src: url("../fonts/martianmono-latin.woff2") format("woff2-variations"),
       url("../fonts/martianmono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+20AC, U+2122;
}
@font-face {
  font-family: "Martian Mono";
  font-style: normal;
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  font-display: swap;
  src: url("../fonts/martianmono-latin-ext.woff2") format("woff2-variations"),
       url("../fonts/martianmono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Libre Barcode EAN13 Text";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/librebarcode-ean13.woff2") format("woff2");
}

/* --------------------------- Design tokens --------------------------- */
:root{
  color-scheme: light;

  --paper:      #F4F0E6;
  --paper-2:    #EBE4D3;
  --paper-3:    #E0D6BF;
  --card:       #FCFAF5;
  --ink:        #1D1A13;
  --ink-soft:   #6A6252;
  --ink-faint:  #9C9382;
  --line:       #DCD2BB;
  --line-soft:  #E8E0CE;
  --line-strong:#C4B79A;

  --console:    #131209;
  --console-2:  #1E1C12;
  --console-3:  #2A2718;
  --console-line: #3B3724;
  --console-text: #F3EEDE;

  --laser:      #D93A1E;
  --laser-2:    #B72D14;
  --laser-dim:  #F4DDD6;
  --laser-ink:  #7C2110;
  --till:       #2C7549;
  --till-dim:   #DDE9DC;
  --amber:      #A9760C;
  --amber-dim:  #F2E5C4;

  --grade-a: #2C7549;
  --grade-b: #6B8C2C;
  --grade-c: #B39410;
  --grade-d: #BC7418;
  --grade-e: #AE3626;

  --f-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --f-mono: "Martian Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --f-barcode: "Libre Barcode EAN13 Text", var(--f-mono);

  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  --r-card: 14px;
  --r-pill: 999px;

  --shadow-1: 0 1px 2px rgba(29,26,19,.06), 0 8px 20px -14px rgba(29,26,19,.4);
  --shadow-2: 0 2px 6px rgba(29,26,19,.08), 0 20px 44px -26px rgba(29,26,19,.55);
  --shadow-lift: 0 -2px 24px rgba(0,0,0,.45);

  --max-w: 560px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);

  /* spazio da lasciare libero sopra la barra del browser sul telefono */
  --browser-gutter: 22px;
}

[hidden]{ display: none !important; }
*, *::before, *::after{ box-sizing: border-box; }
html{ -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body{ height: 100%; }
body{
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-display);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}
img{ max-width: 100%; display: block; }
button{ font: inherit; color: inherit; }
a{ color: inherit; }
ul{ margin: 0; padding: 0; list-style: none; }
h1,h2,h3,p{ margin: 0; }

:focus-visible{
  outline: 2.5px solid var(--laser);
  outline-offset: 3px;
  border-radius: 4px;
}

.sr-live{ position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.visually-hidden{
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ------------------------------ Shell -------------------------------- */
.app{
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: var(--max-w);
  margin: 0 auto;
  position: relative;
  isolation: isolate;
}

.topbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: calc(var(--s3) + var(--safe-t)) var(--s4) var(--s3);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.5) blur(14px);
  -webkit-backdrop-filter: saturate(1.5) blur(14px);
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--line-soft);
}

.brand{
  display: flex;
  align-items: center;
  gap: var(--s3);
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
}
.brand-mark{
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 20px;
  flex: none;
}
.brand-mark span{ display: block; width: 2.5px; background: var(--ink); border-radius: 1px; }
.brand-mark span:nth-child(1){ height: 55%; }
.brand-mark span:nth-child(2){ height: 100%; width: 4px; }
.brand-mark span:nth-child(3){ height: 42%; }
.brand-mark span:nth-child(4){ height: 88%; width: 4px; }
.brand-mark span:nth-child(5){ height: 66%; }
.brand-text{ display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.brand-name{
  font-weight: 800;
  font-stretch: 116%;
  font-size: 18px;
  letter-spacing: -0.015em;
  line-height: 1;
}
.brand-sub{
  font-family: var(--f-mono);
  font-weight: 500;
  font-size: 8.5px;
  letter-spacing: .16em;
  color: var(--ink-faint);
  text-transform: uppercase;
  line-height: 1;
}

.topbar-actions{ display: flex; gap: var(--s2); flex: none; }

.icon-btn{
  appearance: none;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  width: 40px; height: 40px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color .16s ease, transform .12s ease, border-color .16s ease;
  flex: none;
  text-decoration: none;
}
.icon-btn svg{ width: 18px; height: 18px; }
.icon-btn:hover{ background: var(--paper-2); }
.icon-btn:active{ transform: scale(.93); }
.icon-btn[aria-pressed="true"]{ background: var(--ink); border-color: var(--ink); color: var(--paper); }

main{ flex: 1; display: flex; flex-direction: column; min-height: 0; }
.view{ display: none; flex: 1; min-height: 0; flex-direction: column; }
.view[data-active="true"]{ display: flex; }

/* ----------------------------- Banner -------------------------------- */
.banner{
  display: none;
  align-items: center;
  gap: var(--s3);
  padding: 10px var(--s4);
  font-family: var(--f-mono);
  font-size: 11.5px;
  letter-spacing: .02em;
  justify-content: center;
  color: var(--console-text);
  background: var(--ink);
}
.banner[data-visible="true"]{ display: flex; }
.banner .dot{ width: 6px; height: 6px; border-radius: 50%; background: var(--laser); flex: none; }
.banner-btn{
  background: var(--laser); color: #fff; border: none;
  border-radius: var(--r-pill); padding: 5px 13px;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: .04em;
  cursor: pointer; flex: none;
}
.banner-x{
  background: none; border: none; color: currentColor; opacity: .55;
  font-size: 15px; line-height: 1; cursor: pointer; padding: 2px 4px; flex: none;
}
#updateBanner{ background: var(--till); }
#updateBanner .banner-btn{ background: var(--ink); }

/* ============================ SCANSIONE ============================== */
.scan-view{ background: var(--console); color: var(--console-text); position: relative; }

.viewfinder{
  position: relative;
  flex: 1;
  min-height: 300px;
  background: var(--console);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.viewfinder video{
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  background: var(--console);
}

/* velo scuro sopra il video, per far risaltare mirino e comandi */
.viewfinder::after{
  content: "";
  position: absolute; inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(19,18,9,.55) 0%, rgba(19,18,9,0) 22%, rgba(19,18,9,0) 62%, rgba(19,18,9,.72) 100%);
}

.reticle{
  position: relative;
  z-index: 2;
  width: min(82%, 360px);
  aspect-ratio: 5 / 3;
  pointer-events: none;
}
.reticle .corner{
  position: absolute;
  width: 30px; height: 30px;
  border: 3px solid var(--console-text);
  border-radius: 3px;
  opacity: .92;
  transition: border-color .25s ease;
}
.reticle .corner.tl{ top: -3px; left: -3px; border-right: none; border-bottom: none; border-top-left-radius: 10px; }
.reticle .corner.tr{ top: -3px; right: -3px; border-left: none; border-bottom: none; border-top-right-radius: 10px; }
.reticle .corner.bl{ bottom: -3px; left: -3px; border-right: none; border-top: none; border-bottom-left-radius: 10px; }
.reticle .corner.br{ bottom: -3px; right: -3px; border-left: none; border-top: none; border-bottom-right-radius: 10px; }

.laser{
  position: absolute;
  left: 5%; right: 5%;
  top: 50%;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--laser) 14%, #FF6B4A 50%, var(--laser) 86%, transparent);
  box-shadow: 0 0 12px 2px rgba(217,58,30,.6);
  animation: sweep 2.4s cubic-bezier(.6,0,.4,1) infinite;
}
@keyframes sweep{ 0%,100%{ top: 10%; } 50%{ top: 90%; } }

.reticle[data-lock="true"] .corner{ border-color: #58D68D; opacity: 1; }
.reticle[data-lock="true"] .laser{
  animation: none; top: 50%;
  background: #58D68D;
  box-shadow: 0 0 16px 3px rgba(88,214,141,.6);
}

.vf-message{
  position: relative;
  z-index: 3;
  text-align: center;
  padding: 0 var(--s5);
  max-width: 330px;
}
.vf-message .glyph{
  font-family: var(--f-barcode);
  font-size: 58px;
  line-height: 1;
  color: var(--console-text);
  opacity: .38;
  margin-bottom: var(--s3);
  user-select: none;
}
.vf-message p{ font-size: 14px; line-height: 1.55; color: var(--console-text); opacity: .82; }
.vf-message .pill-btn{ margin-top: var(--s4); }

/* --- console comandi: staccata dal fondo, mai sotto la barra del browser --- */
.console-bar{
  position: relative;
  z-index: 5;
  background: var(--console);
  padding: var(--s5) var(--s5) calc(var(--s5) + var(--safe-b) + var(--browser-gutter));
  text-align: center;
  box-shadow: var(--shadow-lift);
}

.scan-status{
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-family: var(--f-mono);
  font-size: 11.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--console-text);
  opacity: .72;
  margin-bottom: var(--s4);
  min-height: 16px;
}
.scan-status .beacon{
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--laser);
  flex: none;
  animation: pulse 1.5s ease-in-out infinite;
}
.scan-status[data-state="idle"] .beacon{ background: var(--ink-faint); animation: none; }
.scan-status[data-state="hit"] .beacon{ background: #58D68D; animation: none; }
@keyframes pulse{ 0%,100%{ opacity: 1; transform: scale(1); } 50%{ opacity: .35; transform: scale(.7); } }

.cta{
  appearance: none;
  border: none;
  width: 100%;
  border-radius: var(--r-pill);
  padding: 19px 26px;
  background: linear-gradient(180deg, #E8492B 0%, var(--laser) 55%, var(--laser-2) 100%);
  color: #fff;
  font-family: var(--f-display);
  font-weight: 800;
  font-stretch: 108%;
  font-size: 16.5px;
  letter-spacing: .005em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0,0,0,.22), 0 14px 30px -12px rgba(217,58,30,.75);
  transition: transform .12s ease, box-shadow .2s ease, filter .2s ease;
}
.cta svg{ width: 19px; height: 19px; flex: none; }
.cta:hover{ filter: brightness(1.05); }
.cta:active{ transform: translateY(2px); box-shadow: 0 0 0 rgba(0,0,0,.22), 0 8px 18px -12px rgba(217,58,30,.75); }

.tool-row{
  display: flex;
  justify-content: center;
  gap: var(--s3);
  margin-top: var(--s4);
}
.pill-btn{
  appearance: none;
  border: 1px solid var(--console-line);
  background: var(--console-2);
  color: var(--console-text);
  border-radius: var(--r-pill);
  padding: 11px 18px;
  font-family: var(--f-mono);
  font-size: 11.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  cursor: pointer;
  transition: background-color .16s ease, transform .12s ease, border-color .16s ease;
  text-decoration: none;
}
.pill-btn svg{ width: 15px; height: 15px; flex: none; }
.pill-btn:hover{ border-color: var(--laser); background: var(--console-3); }
.pill-btn:active{ transform: scale(.95); }
.pill-btn[aria-pressed="true"]{ background: var(--laser); border-color: var(--laser); color: #fff; }
.pill-btn.icon-only{ padding: 11px 14px; }

.manual-link{
  display: inline-block;
  margin-top: var(--s4);
  font-family: var(--f-mono);
  font-size: 11.5px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--console-text);
  opacity: .62;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}
.manual-link:hover{ opacity: 1; }

/* =========================== INSERIMENTO ============================= */
.manual-view{ padding: var(--s5) var(--s4) var(--s7); }
.back-btn{ margin-bottom: var(--s5); }
.page-title{
  font-size: clamp(24px, 7vw, 30px);
  font-weight: 800;
  font-stretch: 112%;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin-bottom: var(--s2);
}
.lede{ color: var(--ink-soft); font-size: 15px; line-height: 1.55; margin-bottom: var(--s6); }

.field{ margin-bottom: var(--s5); }
.field label{
  display: block;
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: var(--s2);
}
.field input{
  width: 100%;
  border: 1.5px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  border-radius: 10px;
  padding: 16px;
  font-family: var(--f-mono);
  font-size: 21px;
  letter-spacing: .08em;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.field input:focus{
  border-color: var(--ink);
  outline: none;
  box-shadow: 0 0 0 4px rgba(29,26,19,.07);
}
.field-note{ margin-top: var(--s2); font-size: 12.5px; color: var(--ink-faint); }

.btn{
  appearance: none;
  border: none;
  border-radius: var(--r-pill);
  padding: 16px 24px;
  font-family: var(--f-display);
  font-weight: 700;
  font-stretch: 106%;
  font-size: 15.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  width: 100%;
  text-decoration: none;
  transition: transform .12s ease, background-color .18s ease;
}
.btn:active{ transform: scale(.985); }
.btn-primary{ background: var(--ink); color: var(--paper); box-shadow: var(--shadow-1); }
.btn-primary:hover{ background: #2E2819; }
.btn-ghost{ background: transparent; color: var(--ink-soft); border: 1.5px solid var(--line-strong); }
.btn-ghost:hover{ background: var(--paper-2); }

/* ============================= RISULTATO ============================= */
.product-view{ background: var(--paper); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.result-topbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--s3) + var(--safe-t)) var(--s4) var(--s2);
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.result-wrap{ padding: var(--s2) var(--s4) var(--s8); display: flex; flex-direction: column; gap: var(--s4); }

/* --- Card 1: il codice così com'è --- */
.code-card{
  background: var(--console);
  color: var(--console-text);
  border-radius: var(--r-card);
  overflow: hidden;
  box-shadow: var(--shadow-2);
  animation: rise .5s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes rise{ from{ opacity: 0; transform: translateY(10px); } to{ opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce){
  .code-card, .off-card{ animation: none; }
}

.code-card-head{
  padding: var(--s5) var(--s5) var(--s4);
  text-align: center;
  border-bottom: 1px solid var(--console-line);
}
.eyebrow{
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: .2em;
  text-transform: uppercase;
  opacity: .55;
  margin-bottom: var(--s3);
}
.code-digits{
  font-family: var(--f-mono);
  font-weight: 600;
  font-size: clamp(21px, 6.4vw, 27px);
  letter-spacing: .1em;
  line-height: 1.15;
  word-break: break-all;
}
.code-bars{
  display: flex;
  justify-content: center;
  padding: var(--s4) var(--s5) 0;
}
.code-bars svg{ width: 100%; max-width: 250px; height: 62px; }

.code-badges{
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  justify-content: center;
  padding: var(--s4) var(--s5);
}
.chip{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--r-pill);
  padding: 7px 13px;
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  border: 1px solid var(--console-line);
  background: var(--console-2);
  color: var(--console-text);
}
.chip[data-tone="ok"]{ background: rgba(88,214,141,.14); border-color: rgba(88,214,141,.45); color: #8FE3B3; }
.chip[data-tone="bad"]{ background: rgba(217,58,30,.16); border-color: rgba(217,58,30,.5); color: #FF9E85; }
.chip[data-tone="warn"]{ background: rgba(169,118,12,.18); border-color: rgba(169,118,12,.5); color: #E8C87A; }

.code-rows{ padding: 0 var(--s5) var(--s5); }
.row{
  display: flex;
  align-items: baseline;
  gap: var(--s2);
  font-family: var(--f-mono);
  font-size: 12.5px;
  padding: 7px 0;
}
.row .k{ white-space: nowrap; opacity: .62; }
.row .leader{
  flex: 1;
  border-bottom: 1px dotted currentColor;
  opacity: .22;
  transform: translateY(-4px);
  min-width: 10px;
}
.row .v{ white-space: nowrap; font-weight: 600; text-align: right; }
.row .v.wrap{ white-space: normal; text-align: right; }

.code-note{
  margin: 0 var(--s5) var(--s5);
  padding: var(--s3) var(--s4);
  border-radius: 10px;
  background: var(--console-2);
  border: 1px solid var(--console-line);
  font-size: 12.5px;
  line-height: 1.55;
  opacity: .82;
}
.code-note strong{ opacity: 1; }

/* struttura del codice, cifra per cifra */
.code-split{
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  padding: 0 var(--s5) var(--s5);
}
.split-part{
  flex: 1 1 auto;
  min-width: 0;
  background: var(--console-2);
  border: 1px solid var(--console-line);
  border-radius: 9px;
  padding: 10px 12px;
  text-align: center;
}
.split-part .pv{
  font-family: var(--f-mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .06em;
  word-break: break-all;
}
.split-part .pk{
  font-family: var(--f-mono);
  font-size: 8.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  opacity: .5;
  margin-top: 4px;
}

/* --- Card 2: Open Food Facts --- */
.off-card{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  overflow: hidden;
  box-shadow: var(--shadow-1);
  animation: rise .5s .07s cubic-bezier(.2,.7,.2,1) both;
}

.off-link{
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s4) var(--s5);
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--line-soft);
  transition: background-color .16s ease;
}
.off-link:hover{ background: var(--paper-2); }
.off-logo{
  width: 38px; height: 38px;
  border-radius: 9px;
  background: var(--ink);
  color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.off-logo svg{ width: 20px; height: 20px; }
.off-link-text{ flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.off-link-title{ display: block; font-weight: 700; font-size: 14.5px; letter-spacing: -0.005em; line-height: 1.2; }
.off-link-sub{
  display: block;
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: .03em;
  color: var(--ink-faint);
  line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.off-link .arrow{ color: var(--ink-faint); flex: none; }
.off-link .arrow svg{ width: 17px; height: 17px; }

.off-hero{
  display: flex;
  gap: var(--s4);
  padding: var(--s5);
  align-items: flex-start;
  border-bottom: 1px dashed var(--line);
}
.off-thumb{
  width: 74px; height: 74px;
  border-radius: 10px;
  background: var(--paper-2);
  flex: none;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.off-thumb img{ width: 100%; height: 100%; object-fit: contain; }
.off-thumb .glyph{ font-family: var(--f-barcode); font-size: 34px; color: var(--ink-faint); }
.off-hero-text{ flex: 1; min-width: 0; }
.off-brand{
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
.off-name{
  font-weight: 800;
  font-stretch: 112%;
  font-size: clamp(19px, 5.4vw, 23px);
  line-height: 1.12;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.off-qty{ font-size: 13.5px; color: var(--ink-soft); margin-top: 5px; }

.grades{
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  padding: var(--s4) var(--s5);
  border-bottom: 1px dashed var(--line);
}
.grade{
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: var(--r-pill);
  padding: 6px 13px 6px 7px;
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  background: var(--paper-2);
}
.grade-chip{
  width: 21px; height: 21px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--f-mono); font-weight: 700; font-size: 11px;
  color: #fff; flex: none;
}
.grade-chip[data-grade="a"]{ background: var(--grade-a); }
.grade-chip[data-grade="b"]{ background: var(--grade-b); }
.grade-chip[data-grade="c"]{ background: var(--grade-c); }
.grade-chip[data-grade="d"]{ background: var(--grade-d); }
.grade-chip[data-grade="e"]{ background: var(--grade-e); }
.grade-chip[data-grade="unknown"]{ background: var(--ink-faint); }

.sect{ padding: var(--s5); border-bottom: 1px dashed var(--line); }
.sect:last-child{ border-bottom: none; }
.sect h2{
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: var(--s3);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
}
.sect h2 .unit{ text-transform: none; letter-spacing: .02em; color: var(--ink-faint); font-size: 9.5px; }
.prose{ font-size: 13.5px; line-height: 1.62; }
.muted{ font-size: 13px; color: var(--ink-faint); font-style: italic; }

.ledger .row{ color: var(--ink); font-size: 13px; }
.ledger .row .k{ opacity: 1; color: var(--ink); }
.ledger .row .leader{ opacity: .35; }
.ledger .row.sub .k{ padding-left: var(--s4); color: var(--ink-soft); }
.ledger .row.sub .v{ color: var(--ink-soft); font-weight: 500; }

.tags{ display: flex; flex-wrap: wrap; gap: 6px; }
.tag{
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  background: var(--paper-2);
}
.tag[data-tone="warn"]{ background: var(--amber-dim); color: var(--laser-ink); border-color: transparent; }
.tag[data-tone="good"]{ background: var(--till-dim); color: var(--till); border-color: transparent; }

.off-empty{ padding: var(--s6) var(--s5); text-align: center; }
.off-empty .glyph{ font-family: var(--f-barcode); font-size: 44px; color: var(--ink-faint); margin-bottom: var(--s3); }
.off-empty h3{ font-size: 17px; font-weight: 800; font-stretch: 108%; margin-bottom: var(--s2); }
.off-empty p{ font-size: 13.5px; color: var(--ink-soft); line-height: 1.55; margin-bottom: var(--s5); }

.result-actions{ display: flex; flex-direction: column; gap: var(--s3); margin-top: var(--s2); }

.loading{ padding: var(--s8) var(--s5); text-align: center; color: var(--ink-soft); }
.spinner{
  width: 32px; height: 32px;
  margin: 0 auto var(--s4);
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--laser);
  animation: spin .8s linear infinite;
}
@keyframes spin{ to{ transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce){ .spinner{ animation: spin 1.6s steps(8) infinite; } }

/* ============================ CRONOLOGIA ============================= */
.history-view{ padding: var(--s4) var(--s4) var(--s8); overflow-y: auto; }
.history-head{
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: var(--s5); padding-top: var(--s2); gap: var(--s3);
}
.history-head h1{ font-size: 26px; font-weight: 800; font-stretch: 110%; letter-spacing: -0.02em; }
.text-btn{
  background: none; border: none; cursor: pointer;
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-soft);
  text-decoration: underline; text-underline-offset: 4px;
  flex: none;
}

.empty{ text-align: center; padding: var(--s8) var(--s4); color: var(--ink-soft); }
.empty .glyph{ font-family: var(--f-barcode); font-size: 46px; color: var(--ink-faint); margin-bottom: var(--s3); }
.empty p{ font-size: 14px; line-height: 1.55; }

.history-list{ display: flex; flex-direction: column; gap: var(--s2); }
.history-item{
  display: flex; align-items: center; gap: var(--s3);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: var(--s3);
  cursor: pointer; text-align: left; width: 100%;
  appearance: none;
  transition: border-color .16s ease, transform .12s ease;
}
.history-item:hover{ border-color: var(--line-strong); }
.history-item:active{ transform: scale(.99); }
.history-item .thumb{
  width: 46px; height: 46px; border-radius: 8px;
  background: var(--paper-2); flex: none; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.history-item .thumb img{ width: 100%; height: 100%; object-fit: contain; }
.history-item .thumb .glyph{ font-family: var(--f-barcode); font-size: 26px; color: var(--ink-faint); }
.history-item .meta{ flex: 1; min-width: 0; }
.history-item .name{ font-size: 14.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item .sub{
  font-family: var(--f-mono); font-size: 10.5px; color: var(--ink-faint);
  margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-item.nf .name{ color: var(--ink-faint); font-style: italic; font-weight: 500; }

/* ------------------------------- Toast -------------------------------- */
.toast{
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-b));
  transform: translate(-50%, 12px);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--f-mono);
  font-size: 12px;
  padding: 12px 20px;
  border-radius: var(--r-pill);
  box-shadow: 0 14px 34px -10px rgba(0,0,0,.55);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  max-width: calc(100% - 40px);
  text-align: center;
}
.toast[data-visible="true"]{ opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 640px){
  body{ background: var(--paper-3); }
  .app{
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    box-shadow: 0 0 80px rgba(29,26,19,.08);
  }
  :root{ --browser-gutter: 0px; }
}
