/* Formula Studio - foglio di stile unico.
   G2: token e convenzioni allineati a LabelLens (pelle "editorial lab": avorio,
   nero caldo, lime come unico segnale decorativo). Il contratto sta in
   DESIGN-labellens.md. Qui e' CSS a mano, non Tailwind: cambiano i nomi, non i
   valori. Deviazione dichiarata: la colonna e' 1100px invece di 768px, perche'
   qui ci sono tabelle a 7 colonne e un grafo, non un report di testo. */

/* ---------- font (self-hosted: la CSP e' font-src 'self') ---------- */
@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-latin-ext.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Fraunces";
  src: url("/fonts/fraunces-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Fraunces";
  src: url("/fonts/fraunces-latin-ext.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Space Mono";
  src: url("/fonts/space-mono-latin.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Space Mono";
  src: url("/fonts/space-mono-latin-ext.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- token ---------- */
:root {
  --surface: #f3f2ec;
  --surface-2: #e9e6dd;
  --card: #fbfaf6;
  --ink: #17161b;
  --muted: #6c6860;
  --line: #dcd7cb;
  --brand: #17161b;
  --brand-700: #2c2a32;
  --brand-soft: #eceae2;
  /* Accent UI in oliva-lime, allineato alla pelle .ll-app di LabelLens
     (contratto DESIGN-labellens.md). Testo #5d7405 su card #fbfaf6 = 5.0:1,
     su --accent-soft #eef4cd = 4.6:1: entrambi sopra AA 4.5. */
  --accent: #5d7405;
  --accent-soft: #eef4cd;
  --signal: #7d9400;
  --signal-soft: #e6f3a3;
  /* CTA-firma LabelLens: lime con testo scuro, identica in dark.
     #17161b su #c6f24a = 13.9:1. */
  --cta: #c6f24a;
  --cta-ink: #17161b;
  --ring: #7d9400;
  --block: #b42318;
  --block-soft: #fbe9e9;
  --warn: #92520a;
  --warn-soft: #fbefd9;
  --note: #33614a;
  --note-soft: #e7f0e9;
  --ok: #2f7d5b;
  --shadow-card: 0 1px 2px rgb(21 34 56 / 0.05), 0 6px 18px -8px rgb(21 34 56 / 0.1);
  --shadow-pop: 0 18px 48px -12px rgb(21 34 56 / 0.28);
  --ease-out-soft: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Fraunces", ui-serif, Georgia, "Times New Roman", serif;
  --font-mono: "Space Mono", ui-monospace, "SF Mono", monospace;
  --col: 1100px;
}

/* Il blocco scuro sta in @media screen: la scheda campione stampata resta
   sempre chiara, inchiostro scuro su carta bianca. */
@media screen {
  html.dark {
    --surface: #16151a;
    --surface-2: #1f1d23;
    --card: #221f27;
    --ink: #f1efe7;
    --muted: #a39d92;
    --line: #322f38;
    /* Oliva piu' chiara dell'equivalente LabelLens (#82981a invece di
       #6e8011): --brand fa ancora da tinta di marca su chip, note e bolle
       con testo chiaro/scuro sopra, e la versione scura non reggeva AA.
       La CTA primaria NON passa piu' da qui: usa --cta (lime, testo scuro). */
    --brand: #82981a;
    --brand-700: #8fa71a;
    --brand-soft: #272a12;
    /* Accent oliva-lime in dark: #b6d62f su card #221f27 = 10.0:1,
       su --accent-soft #262d10 = 8.8:1. */
    --accent: #b6d62f;
    --accent-soft: #262d10;
    --signal: #b6d62f;
    --signal-soft: #2c3a0e;
    --ring: #b6d62f;
    --block: #ef6f63;
    --block-soft: #381e1c;
    --warn: #dca44e;
    --warn-soft: #322715;
    --note: #6cae82;
    --note-soft: #1b2a21;
    --ok: #46b485;
    --shadow-card: 0 1px 2px rgb(0 0 0 / 0.3), 0 6px 18px -8px rgb(0 0 0 / 0.45);
    --shadow-pop: 0 18px 48px -12px rgb(0 0 0 / 0.65);
  }
}

/* ---------- base ---------- */
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
}
body {
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern", "calt";
}
h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.025em;
  font-optical-sizing: auto;
}
h1 {
  font-size: 1.5rem;
}
h2 {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0;
}
h3 {
  font-size: 1rem;
}
a {
  color: var(--ink);
  text-decoration-color: color-mix(in srgb, var(--ink) 35%, transparent);
  text-underline-offset: 2px;
}
.hidden,
[hidden] {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.hint {
  color: var(--muted);
  font-size: 0.75rem;
}
.subline {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
  max-width: 68ch;
  line-height: 1.6;
}
.mono,
.nums {
  font-variant-numeric: tabular-nums;
}
.mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- controlli ---------- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  transition: border-color 150ms var(--ease-standard), box-shadow 150ms var(--ease-standard);
}
textarea {
  resize: vertical;
  line-height: 1.55;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) center, calc(100% - 10px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}
label {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}
label > input,
label > select,
label > textarea {
  margin-top: 0.25rem;
  color: var(--ink);
}
label.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  font-size: 0.875rem;
}
label.check input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}
.opt {
  color: var(--muted);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border: 1px solid transparent;
  border-radius: 8px;
  /* CTA-firma LabelLens: lime con testo scuro, in ENTRAMBI i temi.
     E' la firma visiva dell'app madre; ghost e danger restano com'erano. */
  background: var(--cta);
  color: var(--cta-ink);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: transform 120ms var(--ease-standard), filter 150ms var(--ease-standard), background-color 150ms var(--ease-standard),
    box-shadow 150ms var(--ease-standard);
}
.btn:hover:not([disabled]) {
  filter: brightness(1.07);
  box-shadow: 0 4px 14px -6px rgb(21 34 56 / 0.22);
}
.btn:active:not([disabled]) {
  transform: translateY(1px) scale(0.985);
}
.btn.small {
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
}
.btn.ghost {
  background: var(--card);
  border-color: var(--line);
  color: var(--ink);
}
.btn.ghost:hover {
  background: var(--surface-2);
}
.btn.danger {
  background: var(--block);
  color: #fff;
}
.btn[disabled] {
  opacity: 0.5;
  cursor: default;
}

/* pillola della barra alta */
.chipbtn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.625rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background-color 150ms var(--ease-standard);
}
.chipbtn:hover {
  background: var(--surface-2);
}
.chipbtn.iconbtn {
  padding: 0.3rem 0.5rem;
}
.themeglyph {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid currentColor;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}
.langchip {
  padding: 0;
  border: 0;
  background: none;
}
.langchip select,
.langsel {
  width: auto;
  padding: 0.25rem 1.75rem 0.25rem 0.625rem;
  font-size: 0.75rem;
  border-radius: 8px;
  background-color: var(--card);
}

/* ---------- guscio: barra alta + tab + colonna centrata ---------- */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: var(--col);
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
}
.brandmark {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
}
.logomark {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 9px;
  background: var(--brand);
  position: relative;
}
.logomark::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 3px 3px 5px 5px;
  border: 1.6px solid var(--card);
  border-top-width: 4px;
}
.wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.025em;
  font-size: 1.25rem;
}
.wordmark.small {
  font-size: 1rem;
}
.wordmark span {
  color: var(--muted);
}
.tenant-sep {
  width: 1px;
  height: 20px;
  background: var(--line);
  flex: none;
}
.tenant {
  color: var(--muted);
  font-size: 0.8125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: none;
}
.userchip {
  color: var(--muted);
  font-size: 0.75rem;
  max-width: 16ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tabs {
  display: flex;
  gap: 1.25rem;
  max-width: var(--col);
  margin: 0 auto;
  padding: 0 1.5rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tabs a {
  flex: none;
  padding: 0 0.125rem 0.625rem;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 0.875rem;
  text-decoration: none;
  white-space: nowrap;
}
.tabs a:hover {
  color: var(--ink);
}
.tabs a[aria-current="page"] {
  color: var(--ink);
  font-weight: 500;
  border-bottom-color: var(--signal);
}
.main {
  flex: 1;
  width: 100%;
  max-width: var(--col);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}
.main > section {
  animation: fade-in-up 220ms var(--ease-out-soft) both;
}

.pagehead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
/* La firma visiva: il righello lime sotto ogni titolo di pagina. */
.pagehead h1::after {
  content: "";
  display: block;
  width: 40px;
  height: 3px;
  margin-top: 0.5rem;
  border-radius: 999px;
  background: var(--signal);
}
.pagehead-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.backlink {
  display: inline-block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.8125rem;
  text-decoration: none;
}
.backlink:hover {
  color: var(--ink);
}

/* ---------- card, pannelli, righe ---------- */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  margin-bottom: 1.25rem;
}
.panel > h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.panel > h2::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--signal);
  flex: none;
}
.empty {
  margin: 1.5rem 0;
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--muted);
  font-size: 0.875rem;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.searchrow {
  margin-bottom: 0.75rem;
}
.listcount {
  margin: 0 0 0.75rem;
}

/* elenco compatto (P1, vista di default) */
.rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.frow {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 1rem;
  padding: 0.625rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow-card);
  text-decoration: none;
  transition: transform 180ms var(--ease-standard), box-shadow 180ms var(--ease-standard), border-color 180ms var(--ease-standard);
}
.frow:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px -12px rgb(21 34 56 / 0.18);
  border-color: color-mix(in srgb, var(--brand) 22%, var(--line));
}
.frow-code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}
.frow-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.frow-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.frow-meta {
  color: var(--muted);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.frow-tags {
  display: flex;
  gap: 0.25rem;
}
.frow-vegan {
  color: var(--muted);
  font-size: 0.6875rem;
  white-space: nowrap;
}

/* vista a card */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}
.fcard {
  display: block;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow-card);
  text-decoration: none;
  transition: transform 180ms var(--ease-standard), box-shadow 180ms var(--ease-standard), border-color 180ms var(--ease-standard);
}
.fcard:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px -12px rgb(21 34 56 / 0.18);
  border-color: color-mix(in srgb, var(--brand) 22%, var(--line));
}
.fcard h3 {
  font-size: 0.9375rem;
}
.fcard .meta {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.75rem;
}
.tagrow {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.625rem;
}
.tag {
  padding: 0.125rem 0.5rem;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.625rem;
  font-weight: 500;
}

/* filtro per tag (P2) */
.tagfilter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.tagfilter-label {
  color: var(--muted);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}
.tagfilter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.tagchip {
  padding: 0.125rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font: inherit;
  font-size: 0.6875rem;
  cursor: pointer;
  transition: background-color 150ms var(--ease-standard);
}
.tagchip:hover {
  color: var(--ink);
}
.tagchip.on {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--card);
}

/* selettore segmentato */
.segmented {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
}
.segmented button {
  padding: 0.3rem 0.875rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
}
.segmented button.on {
  background: var(--card);
  color: var(--ink);
  font-weight: 500;
  box-shadow: var(--shadow-card);
}
.segmented.small button {
  padding: 0.2rem 0.625rem;
  font-size: 0.75rem;
}
.viewtoggle {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.viewtoggle button {
  padding: 0.25rem 0.625rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}
.viewtoggle button.on {
  background: var(--card);
  color: var(--ink);
}

/* ---------- input universale (N5 / L2) ---------- */
.uin-drop {
  position: relative;
  border: 2px dashed var(--line);
  border-radius: 8px;
  background: var(--card);
  transition: border-color 150ms var(--ease-standard), background-color 150ms var(--ease-standard);
}
.uin-drop.over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.uin-text {
  width: 100%;
  border: 0;
  background: none;
  padding: 0.75rem;
  font-size: 0.875rem;
}
.uin-text:focus {
  box-shadow: none;
}
.uin-drop:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.uin-dropnote {
  position: absolute;
  right: 0.75rem;
  bottom: 0.5rem;
  color: var(--muted);
  font-size: 0.6875rem;
  pointer-events: none;
}
.uin-bar {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.uin-voice.on {
  border-color: var(--block);
  color: var(--block);
}
.uin-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.5rem;
}
.uin-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.2rem 0.375rem 0.2rem 0.625rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.6875rem;
}
.uin-chip.ok {
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  background: var(--accent-soft);
  color: var(--accent);
}
.uin-chip.error {
  border-color: color-mix(in srgb, var(--block) 30%, transparent);
  background: var(--block-soft);
  color: var(--block);
}
.uin-x {
  border: 0;
  background: none;
  color: inherit;
  font-size: 0.875rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
}
.uin-x:hover {
  opacity: 1;
}
.uin-hint {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.6875rem;
  line-height: 1.5;
}

/* ---------- form record ---------- */
.recordform .formgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.875rem;
}
.recordform .formgrid + .formgrid {
  margin-top: 0.875rem;
}
.fieldnote {
  margin: 0.5rem 0 1.125rem;
  padding-bottom: 1.125rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
label.wide {
  display: block;
  margin-top: 0.875rem;
}
#pt-category {
  margin-bottom: 0.375rem;
}
.tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.625rem;
  cursor: help;
  vertical-align: middle;
}
.quickpick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.375rem;
}
.quickbtn {
  padding: 0.125rem 0.5rem;
  border: 1px dashed color-mix(in srgb, var(--brand) 50%, transparent);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 0.6875rem;
  cursor: pointer;
}
.quickbtn:hover {
  background: var(--surface-2);
}
.precheck-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.precheck-out {
  flex-basis: 100%;
  font-size: 0.8125rem;
}
.precheck-out .pc-hit {
  padding: 0.625rem 1rem;
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  border-radius: 8px;
  background: var(--warn-soft);
  color: var(--warn);
}
.precheck-out .pc-hit a {
  color: inherit;
}
.precheck-out .pc-none {
  color: var(--muted);
}
.moredata {
  margin-bottom: 1rem;
}
.moredata summary {
  color: var(--muted);
  font-size: 0.8125rem;
  cursor: pointer;
}
.moredata label {
  margin-top: 0.625rem;
}
.formerr {
  margin: 0.625rem 0;
  color: var(--block);
  font-size: 0.8125rem;
}
.formerr:not(:empty) {
  padding: 0.5rem 0.75rem;
  border: 1px solid color-mix(in srgb, var(--block) 30%, transparent);
  border-radius: 8px;
  background: var(--block-soft);
}

/* ---------- dettaglio formula ---------- */
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
  margin-bottom: 1.25rem;
}
.detail-note {
  margin-bottom: 1rem;
  padding: 0.625rem 1rem;
  border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
  border-radius: 8px;
  background: var(--brand-soft);
  font-size: 0.8125rem;
}
.detail-note a {
  margin-right: 0.25rem;
}
.tablewrap {
  overflow-x: auto;
  margin-top: 0.75rem;
}
.ingtable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}
.ingtable th {
  padding: 0.25rem 0.5rem;
  color: var(--muted);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
.ingtable td {
  padding: 0.375rem 0.5rem;
  border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  vertical-align: top;
}
.ingtable td.num {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.ingtable .fn {
  color: var(--muted);
}
.flag {
  display: inline-block;
  margin-right: 0.25rem;
  padding: 0.05rem 0.375rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.625rem;
  white-space: nowrap;
}
.flag.allergen {
  background: var(--warn-soft);
  color: var(--warn);
}
.src {
  display: inline-block;
  padding: 0.05rem 0.375rem;
  border-radius: 999px;
  font-size: 0.625rem;
  font-weight: 500;
}
.src.kb {
  background: var(--note-soft);
  color: var(--note);
}
.src.ai {
  background: var(--warn-soft);
  color: var(--warn);
}
.src.user {
  background: var(--brand-soft);
  color: var(--ink);
}
.src.none {
  background: var(--surface-2);
  color: var(--muted);
}
.fieldlist {
  margin: 0.75rem 0 0;
}
.fieldlist dt {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}
.fieldlist dt:first-child {
  margin-top: 0;
}
.fieldlist dd {
  margin: 0.125rem 0 0;
  font-size: 0.8125rem;
}

/* ---------- matcher ---------- */
.match-inputs .segmented {
  margin-bottom: 0.875rem;
}
.match-inputs form > .hint {
  margin: 0 0 0.5rem;
}
.match-inputs .btn {
  margin-top: 0.75rem;
}
.match-results {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.mcard {
  display: block;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow-card);
  text-decoration: none;
  transition: transform 180ms var(--ease-standard), box-shadow 180ms var(--ease-standard), border-color 180ms var(--ease-standard);
}
.mcard:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px -12px rgb(21 34 56 / 0.18);
  border-color: color-mix(in srgb, var(--brand) 22%, var(--line));
}
.mcard-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.mcard-head h3 {
  font-size: 0.9375rem;
}
.mscore {
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.mtype,
.mcard-head .mtype {
  color: var(--muted);
  font-size: 0.75rem;
}
.mbar {
  height: 4px;
  margin: 0.5rem 0;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.mbar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--signal);
}
.mreason {
  margin: 0.5rem 0;
  font-size: 0.8125rem;
  line-height: 1.6;
}
.mchips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.375rem;
}
.mchips-label {
  margin-right: 0.25rem;
  color: var(--muted);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}
.mchip {
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.6875rem;
}
.mchip.hero {
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: var(--accent-soft);
  color: var(--accent);
}
.mchip.miss {
  border-color: color-mix(in srgb, var(--block) 30%, transparent);
  background: var(--block-soft);
  color: var(--block);
}
.mchip.claim {
  border-color: color-mix(in srgb, var(--brand) 30%, transparent);
  background: var(--brand-soft);
  color: var(--ink);
}

/* ---------- scheda campione ---------- */
.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.sheet-head h2 {
  margin-bottom: 0.25rem;
}
.sheet-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.inline-lang {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  white-space: nowrap;
}
.inline-lang select {
  width: auto;
  padding: 0.25rem 1.75rem 0.25rem 0.5rem;
  font-size: 0.75rem;
}
.sheet-empty {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}
.sheet-warn {
  margin: 0.75rem 0;
  padding: 0.625rem 1rem;
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  border-radius: 8px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.8125rem;
}
.sheet-warn.blocking {
  border-color: color-mix(in srgb, var(--block) 30%, transparent);
  background: var(--block-soft);
  color: var(--block);
}
.sheet-warn strong {
  display: block;
  margin-bottom: 0.25rem;
}
.sheet-warn ul {
  margin: 0;
  padding-left: 1.1rem;
}
.sheet-warn li.blk {
  font-weight: 500;
}
.sheet-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  margin-top: 1rem;
  align-items: start;
}
.sheet-editor .f {
  margin-bottom: 0.75rem;
}
.sheet-editor .f input,
.sheet-editor .f textarea,
.sheet-editor textarea {
  margin-top: 0.25rem;
}
.sheet-side {
  position: sticky;
  top: 6.5rem;
}
.sheet-savebar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}
.sheet-status {
  color: var(--muted);
  font-size: 0.75rem;
}
.ing-rows {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.ing-row {
  display: flex;
  gap: 0.375rem;
  align-items: center;
}
.ing-row input {
  margin: 0;
}
.ing-row .btn-x {
  flex: none;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
}
.ing-row .btn-x:hover {
  background: var(--block-soft);
  color: var(--block);
}
.ing-add {
  margin-top: 0.375rem;
}

/* anteprima stampabile: fondo sempre chiaro, e' carta */
.sheet-preview,
#sheet-print-area,
#line-print-area {
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: #17161b;
  font-size: 0.8125rem;
}
#sheet-print-area *,
#line-print-area * {
  color: inherit;
}
.sp-brand {
  display: flex;
  margin-bottom: 0.75rem;
}
.sp-brand.align-center {
  justify-content: center;
}
.sp-brand.align-right {
  justify-content: flex-end;
}
.sp-brand img {
  max-height: calc(40px * var(--logo-scale, 1));
  max-width: calc(180px * var(--logo-scale, 1));
  object-fit: contain;
}
.sp-brand .sp-wordmark {
  font-family: var(--font-display);
  font-weight: 600;
}
.sp-name {
  font-family: var(--font-display);
  font-size: 1.125rem;
}
.sp-tagline {
  margin: 0.125rem 0 0;
  color: #6c6860;
  font-style: italic;
}
.sp-h {
  margin-top: 0.75rem;
  color: #6c6860;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}
.sp-desc,
.sp-use,
.sp-suit {
  margin: 0.125rem 0 0;
  line-height: 1.6;
}
.sp-ings {
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
}
.sp-ings li {
  margin-bottom: 0.125rem;
}
.sp-ings b {
  font-weight: 600;
}
.sp-claims {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.25rem;
}
.sp-claims span {
  padding: 0.1rem 0.5rem;
  border: 1px solid #dcd7cb;
  border-radius: 999px;
  font-size: 0.6875rem;
}
.sp-foot {
  margin-top: 1rem;
  padding-top: 0.625rem;
  border-top: 1px solid #dcd7cb;
  color: #6c6860;
  font-size: 0.625rem;
  line-height: 1.5;
}
.sp-company {
  margin-top: 0.5rem;
  color: #6c6860;
  font-size: 0.625rem;
  line-height: 1.5;
}
.sp-company span {
  display: block;
}

/* chat di rifinitura */
.sheet-chat {
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}
.chatlog {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.bubble {
  max-width: 85%;
  padding: 0.5rem 0.875rem;
  border-radius: 16px;
  font-size: 0.8125rem;
  line-height: 1.55;
  white-space: pre-wrap;
}
.bubble.user {
  align-self: flex-end;
  border-bottom-right-radius: 6px;
  background: var(--brand);
  color: var(--card);
}
.bubble.bot {
  align-self: flex-start;
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  background: var(--card);
}
.chatform {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.625rem;
}
.chatform input {
  flex: 1;
}

/* ---------- line builder ---------- */
.line-digest {
  margin-top: 0.5rem;
}
.narrate-row {
  margin: 0 0 1rem;
}
.linebar {
  display: flex;
  height: 6px;
  margin: 0.5rem 0;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
}
.linebar > i {
  display: block;
  height: 100%;
}
.linebar .seg-cov {
  background: var(--ok);
}
.linebar .seg-adp {
  background: var(--warn);
}
.linebar .seg-gap {
  background: var(--line);
}
.line-warnings {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin: 0.5rem 0;
}
.line-warn {
  padding: 0.5rem 0.75rem;
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  border-radius: 8px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.75rem;
}
.lslot {
  margin-top: 0.75rem;
  padding: 0.875rem;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 12px;
  background: var(--card);
}
.lslot.covered {
  border-left-color: var(--ok);
}
.lslot.adapt {
  border-left-color: var(--warn);
}
.lslot.gap {
  border-left-color: var(--block);
}
.lslot-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}
.lslot-head h3 {
  font-size: 0.875rem;
}
.lslot-tag {
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.625rem;
  font-weight: 500;
  white-space: nowrap;
}
.lslot-tag.covered {
  background: var(--note-soft);
  color: var(--note);
}
.lslot-tag.adapt {
  background: var(--warn-soft);
  color: var(--warn);
}
.lslot-tag.gap {
  background: var(--block-soft);
  color: var(--block);
}
.lcand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0;
  border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  font-size: 0.8125rem;
}
.lcand:first-of-type {
  border-top: 0;
}
.lcand input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}
.lcand .lc-name {
  font-weight: 500;
}
.lcand .lc-meta {
  color: var(--muted);
  font-size: 0.75rem;
}
.lcand .lc-fit {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}
.lgap {
  margin-top: 0.375rem;
  color: var(--muted);
  font-size: 0.8125rem;
}
.lgap b {
  color: var(--ink);
}
.line-matrix {
  margin-top: 1rem;
  overflow-x: auto;
}
.line-matrix table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.6875rem;
}
.line-matrix th {
  padding: 0.25rem 0.375rem;
  color: var(--muted);
  font-weight: 500;
  text-align: left;
}
.line-matrix td {
  padding: 0.25rem 0.375rem;
  border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.line-matrix td.b {
  font-weight: 500;
}
.line-matrix td.c {
  text-align: center;
}
.line-matrix td.none {
  color: var(--muted);
}
.lrat {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}
.lrat:first-child {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}
.lrat-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.lrat-badge {
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--ink);
  font-size: 0.625rem;
}
.lrat dl {
  margin: 0.5rem 0 0;
}
.lrat dt {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}
.lrat dd {
  margin: 0.125rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.6;
}

/* ---------- grafo ---------- */
.graph-panel {
  padding: 1rem;
}
.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.graph-legend .lg {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font: inherit;
  font-size: 0.6875rem;
  cursor: pointer;
  user-select: none;
}
.graph-legend .lg:hover {
  color: var(--ink);
}
.graph-legend .lg.off {
  opacity: 0.4;
}
.graph-legend .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}
.graph-wrap {
  position: relative;
  height: 560px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  overflow: hidden;
}
#graph-canvas {
  display: block;
  cursor: grab;
}
#graph-canvas:active {
  cursor: grabbing;
}
.graph-tip {
  position: absolute;
  padding: 0.375rem 0.625rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow-pop);
  font-size: 0.6875rem;
  pointer-events: none;
  max-width: 220px;
}
.graph-tip b {
  display: block;
}
#graph-stats {
  margin: 0.625rem 0 0;
}

/* ---------- team + branding ---------- */
.invite-out {
  margin-top: 0.625rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  word-break: break-all;
}
.authnote {
  margin: 0.25rem 0 0.75rem;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.6;
}
.brandlab {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.5rem;
  margin-top: 0.75rem;
  align-items: start;
}
.brandlab-controls .wide {
  display: block;
  margin-top: 0.875rem;
  color: var(--muted);
  font-size: 0.75rem;
}
.brandlab-controls .segmented {
  margin-top: 0.25rem;
}
input[type="range"] {
  width: 100%;
  margin-top: 0.375rem;
  accent-color: var(--accent);
}
input[type="file"] {
  width: 100%;
  margin-top: 0.25rem;
  font-size: 0.8125rem;
  color: var(--muted);
}
input[type="file"]::file-selector-button {
  margin-right: 0.625rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover {
  background: var(--surface-2);
}
.brandlab-controls > .wide:first-child {
  margin-top: 0;
}
.brandlab-preview .hint {
  margin: 0 0 0.5rem;
}
.brand-sim {
  min-height: 320px;
  display: flex;
  flex-direction: column;
}
.sim-head {
  display: flex;
  padding-bottom: 0.75rem;
}
.sim-head.align-center {
  justify-content: center;
}
.sim-head.align-right {
  justify-content: flex-end;
}
.sim-logo {
  position: relative;
  display: inline-flex;
  padding: 2px;
  border: 1px dashed transparent;
  border-radius: 6px;
  cursor: grab;
  touch-action: none;
}
.sim-logo:hover {
  border-color: #b6c34a;
}
.sim-logo img {
  max-height: calc(40px * var(--logo-scale, 1));
  max-width: calc(180px * var(--logo-scale, 1));
  object-fit: contain;
  pointer-events: none;
}
.sim-logo.empty {
  padding: 0.5rem 0.75rem;
  border: 1px dashed #dcd7cb;
  color: #6c6860;
  font-size: 0.6875rem;
  cursor: default;
}
.sim-handle {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 11px;
  height: 11px;
  border: 1px solid #fff;
  border-radius: 999px;
  background: #7d9400;
  cursor: ew-resize;
}
.sim-body {
  flex: 1;
}
.sim-body h3 {
  font-family: var(--font-display);
  font-size: 1.0625rem;
}
.sim-sub {
  margin: 0.125rem 0 0;
  color: #6c6860;
  font-size: 0.75rem;
}
.sim-label {
  margin: 0.875rem 0 0.125rem;
  color: #6c6860;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}
.sim-inci {
  margin: 0;
  font-size: 0.6875rem;
  line-height: 1.6;
}
.sim-foot {
  margin-top: 1rem;
  padding-top: 0.625rem;
  border-top: 1px solid #dcd7cb;
  color: #6c6860;
  font-size: 0.625rem;
  line-height: 1.6;
}
.sim-foot span {
  display: block;
}
.sim-foot.empty {
  font-style: italic;
  opacity: 0.75;
}

/* ---------- gate di accesso ---------- */
.gate {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 100vh;
}
.gate-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.25rem;
  padding: 3rem;
  background: #17161b;
  color: #f3f2ec;
}
.gate-brand .wordmark {
  font-size: 1.75rem;
  color: #f3f2ec;
}
.gate-brand .wordmark span {
  color: rgb(243 242 236 / 0.55);
}
.gate-claim {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.375rem;
  line-height: 1.35;
  max-width: 22ch;
}
.gate-points {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.gate-points li {
  display: flex;
  gap: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.6;
  opacity: 0.85;
  max-width: 44ch;
}
.gate-points b {
  color: #b6d62f;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}
.gate-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0;
  font-size: 0.75rem;
  opacity: 0.75;
}
.gate-lang {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  color: inherit;
}
.gate-lang .langsel {
  background-color: rgb(255 255 255 / 0.08);
  border-color: rgb(255 255 255 / 0.2);
  color: #f3f2ec;
}
.gate-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
}
.authcard {
  width: 100%;
  max-width: 380px;
  padding: 2rem 1.75rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow-pop);
}
.authcard h1 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}
.authcard form label {
  margin-bottom: 0.75rem;
}
.authcard .btn {
  width: 100%;
  margin-top: 0.5rem;
}
.authnote + form {
  margin-top: 0.75rem;
}
.authswitch {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
}
.authswitch.small {
  margin-top: 0.375rem;
  font-size: 0.75rem;
}
.waitpulse {
  height: 4px;
  margin: 1rem 0;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  position: relative;
}
.waitpulse::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 35%;
  border-radius: 999px;
  background: var(--signal);
  animation: slide 1.3s var(--ease-standard) infinite;
}

/* ---------- movimento ---------- */
@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes slide {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(420%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .main > section,
  .waitpulse::after {
    animation: none !important;
  }
  .btn,
  .frow,
  .fcard,
  .mcard,
  .chipbtn,
  .uin-drop {
    transition: none !important;
  }
  .frow:hover,
  .fcard:hover,
  .mcard:hover {
    transform: none;
  }
  .btn:active {
    transform: none;
  }
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .detail-grid,
  .sheet-workspace,
  .brandlab {
    grid-template-columns: minmax(0, 1fr);
  }
  .sheet-side {
    position: static;
  }
  .gate {
    grid-template-columns: minmax(0, 1fr);
  }
  .gate-brand {
    padding: 2rem 1.5rem;
  }
}
@media (max-width: 640px) {
  .topbar-in,
  .tabs,
  .main {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .main {
    padding-top: 1.5rem;
  }
  .tenant,
  .tenant-sep,
  .userchip {
    display: none;
  }
  /* Su schermo stretto il nome della formula vince su tutto: i tag e il resto
     si leggono nel dettaglio, un nome troncato a "N..." non serve a nessuno. */
  .frow {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.25rem;
  }
  .frow-code,
  .frow-vegan,
  .frow-tags {
    display: none;
  }
  /* I chip di filtro scorrono su una riga sola invece di occupare mezzo schermo. */
  .tagfilter-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 0.25rem;
    -webkit-overflow-scrolling: touch;
  }
  .tagfilter-chips::-webkit-scrollbar {
    display: none;
  }
  .tagchip {
    flex: none;
  }
  .graph-wrap {
    height: 380px;
  }
  h1 {
    font-size: 1.25rem;
  }
}

/* ---------- stampa ---------- */
@page {
  margin: 12mm;
}
@media print {
  .topbar,
  .pagehead-actions,
  .sheet-editor,
  .sheet-savebar,
  .sheet-chat,
  .sheet-head,
  .brandlab-controls {
    display: none !important;
  }
  body,
  .main,
  .panel {
    background: #fff;
    box-shadow: none;
    border: 0;
    padding: 0;
    margin: 0;
  }
  .sheet-preview,
  #sheet-print-area,
  #line-print-area {
    border: 0;
    padding: 0;
  }
}

/* Un tag che nel risultato corrente non porta piu' niente resta cliccabile ma
   smette di promettere: e' informazione, non un bottone morto. */
.tagchip.zero {
  opacity: 0.45;
}

/* Mappa della linea: la stessa resa del grafo, in piccolo, dentro il tabellone. */
.linemap {
  margin-top: 1rem;
}
.linemap .hint {
  margin: 0 0 0.5rem;
}
.linemap-wrap {
  position: relative;
  height: 300px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  overflow: hidden;
}
.linemap-wrap canvas {
  display: block;
  cursor: grab;
}
.linemap-wrap canvas:active {
  cursor: grabbing;
}

/* ---------- parere del professionista ---------- */
.expert-section .chatlog {
  max-height: 380px;
  margin-top: 0.75rem;
}
.expert-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.75rem;
}
.bubble-who {
  align-self: flex-start;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}
.labellens-link {
  display: inline-flex;
  align-items: center;
  margin-left: 0.25rem;
  padding: 0.05rem 0.5rem;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.6875rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.labellens-link:hover {
  background: var(--accent);
  color: var(--card);
}

/* --- modulo documenti ----------------------------------------------------- */
.doc-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.doc-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.doc-blocks { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 0; }
.doc-blocks legend { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 6px; }
#doc-blocklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 16px; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.chk input { flex: none; }
.doc-confidential { border-left: 3px solid var(--brand); padding-left: 12px; }
.doc-confidential .hint { margin: 4px 0 0; }
.doc-savebar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.doc-note {
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--muted);
}
.doc-preview { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #edece7; }
#doc-frame { display: block; width: 100%; height: 70vh; min-height: 420px; border: 0; }
@media (max-width: 640px) {
  #doc-blocklist { grid-template-columns: 1fr; }
  #doc-frame { height: 60vh; }
}

/* --- linee: editor degli slot dedotti + avvisi onesti --------------------- */
.slotedit { display: grid; gap: 10px; margin-bottom: 14px; }
.slotedit-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1.2fr) auto;
  gap: 10px;
  align-items: center;
}
.slotedit-row .slotedit-meta { grid-column: 1 / -1; font-size: 13px; color: var(--muted); margin-top: -4px; }
.slotedit-row input { width: 100%; }
.line-legacy {
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--muted);
}
.lc-unscored { font-style: italic; }
@media (max-width: 640px) {
  .slotedit-row { grid-template-columns: 1fr; }
}

/* --- icone dei bottoni di input ------------------------------------------- */
.uin-bar .btn { display: inline-flex; align-items: center; gap: 7px; }
.uin-icon { width: 15px; height: 15px; flex: none; opacity: .8; }
.btn:hover .uin-icon { opacity: 1; }
.uin-voice.on .uin-icon { color: var(--red, #b3261e); opacity: 1; }

/* --- intestazioni di pagina: la riga sotto il titolo segue il contenuto ----
   Prima .subline era limitata a 68ch (~580px) mentre il pannello sotto ne
   misura ~1050: la frase andava a capo a meta' e il taglio si leggeva come un
   difetto, non come una scelta. Ora il blocco usa la larghezza del contenuto,
   e se una frase lunga va comunque a capo, `balance` distribuisce le righe in
   modo uniforme cosi' il ritorno a capo sembra voluto. */
.pagehead .subline,
.sheet-head .hint {
  max-width: none;
  text-wrap: balance;
}
/* NESSUN tetto in caratteri. Ne avevo lasciato uno a 92ch "per leggibilita'":
   con l'italiano (piu' lungo dell'inglese) o con lo zoom del browser il testo
   tornava a spezzarsi a meta' pannello, cioe' il difetto di partenza. La
   richiesta era esplicita: larga quanto la tabella. La leggibilita' la protegge
   gia' la larghezza massima della colonna centrale. */

/* --- avviso doppioni (automatico, non piu' un bottone) -------------------- */
.precheck-out {
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 0 0 14px;
}
.pc-title { margin: 0 0 8px; font-size: 14px; font-weight: 500; }
.pc-hit { margin: 0 0 4px; font-size: 14px; }
.pc-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* --- tag: stato vegan e tag del produttore -------------------------------- */
.tag--vg-vegan { border-color: color-mix(in oklab, var(--brand) 45%, var(--line)); }
.tag--vg-verify-source { font-style: italic; }
.tag--own { border-style: dashed; }
.tag--del { display: inline-flex; align-items: center; gap: 6px; }
.tagx {
  border: 0; background: none; cursor: pointer; padding: 0 2px;
  color: var(--muted); font-size: 15px; line-height: 1;
}
.tagx:hover { color: var(--ink, inherit); }
#form-own-tag { align-items: center; gap: 8px; margin-top: 10px; }

/* --- menu account (G2) ---------------------------------------------------- */
.acct { position: relative; }
.acct-trigger { display: inline-flex; align-items: center; gap: 8px; }
.acct-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 999px; flex: none;
  background: color-mix(in oklab, var(--brand) 18%, transparent);
  color: var(--brand); font-size: 10px; font-weight: 600; letter-spacing: .02em;
}
.acct-name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-caret {
  width: 0; height: 0; flex: none;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid var(--muted);
  transition: transform 140ms ease;
}
.acct-trigger[aria-expanded="true"] .acct-caret { transform: rotate(180deg); }

.acct-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60;
  width: 260px; max-height: 70vh; overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card, #fff);
  box-shadow: 0 1px 2px rgb(21 34 56 / .05), 0 8px 24px -10px rgb(21 34 56 / .18);
  animation: acct-in 180ms cubic-bezier(.22,.61,.36,1) both;
}
.acct-panel[hidden] { display: none; }
@keyframes acct-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.acct-id { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.acct-eyebrow { margin: 0 0 4px; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.acct-who { margin: 0; font-size: 14px; font-weight: 600; }
.acct-mail, .acct-org { margin: 2px 0 0; font-size: 12px; color: var(--muted); word-break: break-word; }

.acct-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px 16px; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 14px; color: inherit; text-align: left;
}
.acct-item:hover, .acct-item:focus-visible { background: var(--surface-2, rgb(0 0 0 / .04)); }
.acct-item + .acct-item { border-top: 1px solid var(--line); }
.acct-danger:hover, .acct-danger:focus-visible { color: var(--red, #b3261e); }
.acct-ico { width: 15px; height: 15px; flex: none; opacity: .75; }
.acct-ico-out {
  border: 1.5px solid currentColor; border-right-color: transparent;
  border-radius: 3px; opacity: .55;
}
/* Team: due teste stilizzate, stesso tratto minimale delle altre icone. */
.acct-ico-team {
  background:
    radial-gradient(circle 3px at 5px 5px, currentColor 2.4px, transparent 3px),
    radial-gradient(circle 3px at 11px 5px, currentColor 2.4px, transparent 3px),
    radial-gradient(7px 5px at 5px 13px, currentColor 4.6px, transparent 5px),
    radial-gradient(7px 5px at 11px 13px, currentColor 4.6px, transparent 5px);
  opacity: .55;
}
/* Branding: un campione di colore, meta' pieno. */
.acct-ico-brand {
  border: 1.5px solid currentColor; border-radius: 4px;
  background: linear-gradient(135deg, currentColor 48%, transparent 48%);
  opacity: .55;
}
@media (prefers-reduced-motion: reduce) {
  .acct-panel { animation: none; }
  .acct-caret { transition: none; }
}
@media (max-width: 520px) {
  .acct-name { display: none; }
  .acct-panel { width: min(280px, calc(100vw - 24px)); }
}

/* --- consumi (T2) --------------------------------------------------------- */
.usage-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.ustat { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.ustat-l { display: block; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ustat-v { display: block; margin-top: 4px; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.usage-chart {
  display: flex; align-items: flex-end; gap: 3px;
  height: 90px; margin-bottom: 18px; padding: 0 2px;
  border-bottom: 1px solid var(--line);
}
.ubar { flex: 1 1 0; min-width: 3px; height: 100%; display: flex; align-items: flex-end; }
.ubar i { display: block; width: 100%; background: color-mix(in oklab, var(--brand) 55%, transparent); border-radius: 2px 2px 0 0; }
.ubar:hover i { background: var(--brand); }
@media (max-width: 640px) { .usage-stats { grid-template-columns: 1fr; } }

/* --- modulo invito: campo e bottone sulla stessa riga --------------------- */
#form-invite { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 16px; }
#form-invite input { flex: 1 1 260px; min-width: 0; }
#form-invite button { flex: none; }
#form-own-tag input { flex: 1 1 220px; min-width: 0; }
@media (max-width: 520px) { #form-invite input, #form-own-tag input { flex-basis: 100%; } }

/* --- branding: anteprima in proporzioni A4 (T4) --------------------------- */
/* La barra della dimensione non diceva niente finche' non si generava la
   scheda. Ora l'anteprima ha le proporzioni vere di un A4 (1:1.414), quindi
   "grande cosi'" si vede prima, non dopo. */
.brand-sim {
  aspect-ratio: 1 / 1.414;
  min-height: 0;
  max-height: 70vh;
  margin-inline: auto;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sim-foot.align-center { text-align: center; }
.sim-foot.align-right { text-align: right; }

.brandprofiles { margin-top: 14px; }
.brandlist { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.brandchip {
  display: inline-flex; align-items: center;
  border: 1px solid var(--line); border-radius: 999px; overflow: hidden;
}
.brandchip.on { border-color: var(--brand); background: color-mix(in oklab, var(--brand) 10%, transparent); }
.brandchip-use { border: 0; background: none; cursor: pointer; font: inherit; font-size: 13px; padding: 5px 4px 5px 12px; color: inherit; }
.brandchip-x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 15px; line-height: 1; padding: 5px 10px 5px 4px; }
.brandchip-x:hover { color: var(--red, #b3261e); }
#form-brand-new { align-items: center; gap: 8px; }
#form-brand-new input { flex: 1 1 220px; min-width: 0; }

/* --- passata visiva sulla fascia alta (G1) --------------------------------
   Claudio: "il font piu' piccolo o la disposizione delle cose". Misurato e
   corretto, senza ridisegnare niente:
   - le due righe non respiravano uguale: la riga del marchio aveva 12px sopra
     e sotto, le linguette zero sopra e 10 sotto, quindi la fascia sembrava
     schiacciata in basso;
   - le voci di menu a 14px con un'area cliccabile di 33px, sotto i 44px
     minimi per il dito;
   - i comandi a destra a 12px, piu' piccoli del menu che gli sta sotto;
   - il nome dell'azienda competeva col marchio invece di seguirlo. */
.topbar-in { padding: 0.875rem 1.5rem 0.75rem; }
.tabs { padding: 0 1.5rem; gap: 1.5rem; }
.tabs a {
  padding: 0.4rem 0.125rem 0.7rem;
  font-size: 0.9375rem;
  line-height: 1.4;
}
.chipbtn { font-size: 0.8125rem; padding: 0.3rem 0.7rem; }
.tenant { font-size: 0.8125rem; color: var(--muted); }

/* La voce attiva ora si vede davvero: prima il selettore era rimasto quello
   della barra laterale e non si accendeva nessuna voce. */
.tabs a[aria-current="page"] { border-bottom-width: 2px; }

@media (max-width: 640px) {
  .topbar-in { padding: 0.75rem 1rem 0.625rem; }
  .tabs { padding: 0 1rem; gap: 1.15rem; }
  .tabs a { font-size: 0.875rem; }
}

/* Regola di Chanel: via il separatore verticale fra il marchio e il nome
   dell'azienda. Serviva quando i due testi avevano lo stesso peso; ora che il
   nome azienda e' piu' piccolo e in grigio, la differenza la fa gia' la
   tipografia e quella stanghetta e' solo un segno in piu' da guardare. */
.tenant-sep { display: none; }

/* Il piede aziendale della scheda stampata segue l'allineamento scelto (T5).
   Senza queste due righe il comando muoveva solo la simulazione in Team. */
.sp-company.align-center { text-align: center; }
.sp-company.align-right { text-align: right; }

/* --- contrasto in tema scuro (esito del red-team) -------------------------
   Le iniziali dell'avatar stavano a ~3.8:1 (serve 4.5:1 per il testo) e le
   barre dei consumi a ~2.1:1 (serve 3:1 per un oggetto grafico che porta
   informazione). Sono numeri misurati, non impressioni. */
.dark .acct-avatar { color: var(--ink); background: color-mix(in oklab, var(--brand) 30%, transparent); }
.dark .ubar i { background: color-mix(in oklab, var(--brand) 85%, transparent); }

/* --- palette del colore branding ------------------------------------------ */
.brandcolors { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.swatch {
  width: 26px; height: 26px; flex: none;
  border: 2px solid var(--card, #fff); border-radius: 999px;
  background: var(--sw); cursor: pointer; padding: 0;
  box-shadow: 0 0 0 1px var(--line);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.swatch:hover { transform: scale(1.08); }
.swatch.on { box-shadow: 0 0 0 2px var(--sw); transform: scale(1.05); }
.swatch:focus-visible { outline: 2px solid var(--sw); outline-offset: 2px; }
/* La sim del branding riflette il colore scelto. */
.brand-sim { --sim-accent: #4a6b3d; position: relative; }
.brand-sim::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--sim-accent); border-radius: 8px 8px 0 0;
}
.sp-h { color: var(--sim-accent) !important; }

/* --- modulo cataloghi (catalogo visuale, Fase 1) --------------------------- */
/* Il titolo del catalogo E' l'h1 della pagina, solo che si scrive: il campo
   eredita il carattere display e tiene il righello firma del pagehead. */
.cat-headmain { flex: 1 1 320px; min-width: 0; }
.cat-h1 input,
.cat-h1 input[type="text"] {
  width: 100%; min-width: 0; padding: 0 0 2px;
  font: inherit; letter-spacing: inherit; color: inherit;
  background: transparent; border: 0; border-radius: 0;
  border-bottom: 1px dashed transparent; box-shadow: none;
}
.cat-h1 input:hover { border-bottom-color: var(--line); }
.cat-h1 input:focus { outline: none; border-bottom-color: var(--ring); box-shadow: none; }

/* badge di stato del catalogo: bozza neutra, proposta calda, finale verde */
.tag--st-proposal { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }
.tag--st-final { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* una linea nel selettore "Nuovo da linea" resta una riga .frow, ma da bottone */
button.catline { width: 100%; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }

/* le righe catalogo non hanno la colonna del codice lab: senza questa regola
   il titolo finirebbe schiacciato nei 7rem pensati per il codice */
#cat-list .frow,
#cat-linepick-list .frow { grid-template-columns: minmax(0, 1fr) auto; }

/* gruppi: un capitolo = una scheda; il gruppo fuori tema e' tratteggiato,
   perche' nella pagina stampata non ha divisorio */
.catgroup { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; background: var(--card); }
.catgroup.unthemed { border-style: dashed; background: transparent; }
.catgroup-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.catgroup-headmain { min-width: 0; }
.catgroup-head h3 { margin: 0; font-size: 15px; }
.catgroup-mood { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.catgroup-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.catgroup-empty { margin: 6px 0; font-size: 13.5px; color: var(--muted); font-style: italic; }
.cat-rename { display: grid; gap: 6px; width: 100%; margin-bottom: 8px; }

.catitems { display: grid; gap: 4px; margin: 4px 0 10px; }
.catitem { display: grid; grid-template-columns: 1.6rem minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; }
.catitem:hover { background: var(--surface-2); }
.catitem-pos { color: var(--muted); font-size: 12px; }
.catitem-name { min-width: 0; overflow-wrap: anywhere; }
.catitem-name a { color: inherit; text-decoration: none; font-weight: 500; }
.catitem-name a:hover { text-decoration: underline; }
.catitem.missing { border: 1px dashed var(--warn); background: var(--warn-soft); }
.catitem-missingtext { color: var(--warn); font-size: 13.5px; }
.catitem-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

/* selettore formula: pannello inline sotto il punto che l'ha chiesto */
.catpick { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 8px 0; background: var(--surface-2); }
.catpick-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.catpick-q { margin-bottom: 8px; }
.catpick-list { display: grid; gap: 4px; max-height: 300px; overflow: auto; }
.catpick-item { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; text-align: left; border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 8px 10px; cursor: pointer; font: inherit; font-size: 14px; color: inherit; }
.catpick-item:hover, .catpick-item:focus-visible { border-color: var(--ring); }
.catpick-name { font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.catpick-meta { color: var(--muted); font-size: 12.5px; flex: none; }

/* --- slot immagine del catalogo: copertina + carosello (Fase 2b) ----------- */
.catcover { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin-bottom: 12px; background: var(--card); }
.catcover-main { min-width: 0; }
.catcover h3 { margin: 0; font-size: 15px; }

.catimg { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 8px 0 12px; background: var(--surface-2); }
.catimg-hint { margin: 0 0 8px; font-size: 12.5px; color: var(--muted); }
.catimg-status { margin: 0 0 8px; font-size: 13px; color: var(--muted); min-height: 1.2em; }
.catimg-status.err { color: var(--warn); }
.catimg-status:empty { min-height: 0; margin: 0; }

/* Il carosello E' lo storico: una striscia orizzontale append-only, si torna
   indietro scorrendo. Le thumb sono bottoni veri (aria-pressed = selezionata). */
.catimg-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x proximity; }
.catimg-thumb { position: relative; flex: 0 0 auto; width: 136px; display: grid; gap: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); padding: 4px 4px 5px; cursor: pointer; font: inherit; color: inherit; text-align: left; scroll-snap-align: start; }
.catimg-thumb:hover { border-color: var(--ring); }
.catimg-thumb:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.catimg-thumb.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.catimg-imgbox { display: block; width: 100%; aspect-ratio: 4 / 3; border-radius: 5px; overflow: hidden; background: var(--brand-soft); }
.catimg-imgbox img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* La fonte, sempre visibile sotto ogni proposta (obbligo ToS per Pixabay). */
.catimg-srcline { font-size: 11.5px; line-height: 1.3; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
/* Testo del badge in var(--card), non #fff fisso: sull'accent oliva chiaro
   del tema scuro il bianco non reggerebbe AA, la card scura si' (10:1). */
.catimg-selbadge { position: absolute; top: 8px; left: 8px; background: var(--accent); color: var(--card); font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 99px; }
.catimg-thumb.broken .catimg-imgbox { display: grid; place-items: center; }
.catimg-brokentext { font-size: 11.5px; color: var(--muted); padding: 6px; text-align: center; }
.catimg-foot { margin-top: 2px; }
/* F2c: generazione AI nel carosello. Badge in alto a destra (la spunta
   "Scelta" sta a sinistra), pannellino prompt+prezzi, conferma costo hi-res. */
.catimg-aibadge { position: absolute; top: 8px; right: 8px; background: var(--ink); color: var(--card); font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; padding: 2px 7px; border-radius: 5px; }
.catimg-ai { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.catimg-ailabel { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.catimg-aiprompt { width: 100%; box-sizing: border-box; resize: vertical; min-height: 46px; font: inherit; font-size: 13px; line-height: 1.4; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--card); color: var(--ink); }
.catimg-aiprompt:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.catimg-ainote { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.catimg-aicost { color: var(--ink); }
.catimg-airow { align-items: center; flex-wrap: wrap; }
.catimg-ain { width: auto; min-width: 64px; font: inherit; font-size: 13px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--card); color: var(--ink); }
.catimg-confirm { margin-top: 8px; border: 1px solid var(--warn); border-radius: 8px; padding: 10px 12px; background: var(--card); display: grid; gap: 8px; }
.catimg-confirmmsg { margin: 0; font-size: 13px; line-height: 1.45; color: var(--ink); }

.cat-theme-form { align-items: center; }
.cat-theme-form input { flex: 1 1 200px; min-width: 0; }
#cat-frame { display: block; width: 100%; height: 70vh; min-height: 420px; border: 0; }
#cat-msg:empty { display: none; }

@media (max-width: 640px) {
  /* nella lista cataloghi il badge di stato deve restare visibile anche
     stretti: e' l'informazione che distingue una bozza da una proposta */
  #cat-list .frow-tags { display: flex; }
  .catitem { grid-template-columns: 1.4rem minmax(0, 1fr); }
  .catitem-actions { grid-column: 1 / -1; justify-content: flex-start; }
  #cat-frame { height: 60vh; min-height: 320px; }
}

/* ==================== FEEDBACK-04: scheda prodotto ==================== */

/* 1b: tooltip CSS-only dei tag-segnale: hover E focus da tastiera (title
   nativo non si vede su mobile ne' nei test). Il testo sta in data-tip. */
.has-tip {
  position: relative;
  cursor: help;
}
.has-tip::after {
  content: attr(data-tip);
  position: absolute;
  /* sotto-a-destra: i segnali stanno nell'ultima colonna, un tooltip a
     sinistra-sopra finiva tagliato dal bordo del pannello/tablewrap */
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  width: max-content;
  max-width: 240px;
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  font-size: 0.6875rem;
  font-weight: 400;
  line-height: 1.4;
  white-space: normal;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  pointer-events: none;
  transform: translateY(2px);
  transition: opacity 0.12s var(--ease-standard), transform 0.12s var(--ease-standard);
}
.has-tip:hover::after,
.has-tip:focus-visible::after,
.has-tip:focus::after {
  opacity: 1;
  transform: translateY(0);
}

/* 1c/1d: override rapidi di vegan (si/no) e origine (tendina) in tabella. */
.ovtoggle {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
}
.ovbtn {
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: 0.6875rem;
  line-height: 1.3;
  cursor: pointer;
}
.ovbtn.on {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--card);
}
.ovdep {
  margin-left: 0.25rem;
  font-size: 0.6875rem;
}
.ovselect {
  /* il select globale e' width:100%: qui serve la larghezza del contenuto
     (il valore piu' lungo e' "sintetica"), non quella della colonna */
  width: auto;
  min-width: 6.75rem;
  padding: 0.1rem 1.5rem 0.1rem 0.375rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background-color: var(--card);
  background-position: calc(100% - 12px) center, calc(100% - 7px) center;
  color: inherit;
  font: inherit;
  font-size: 0.75rem;
}

/* 6b: riservatezza a livello record, nel pannello Scheda. */
.rec-conf {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  font-size: 0.8125rem;
}
.rec-conf .chk {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

/* 2g: riga dei free-from derivati. */
.ffrow {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

/* Punto 5 (rivisto su feedback): i tag del produttore con la STESSA anatomia
   delle sezioni sotto (titolo, hint, contenuto, input largo + bottone primario
   a destra). La striscia compatta si leggeva come un corpo estraneo. */
.own-tags-panel .tagrow {
  margin: 0.625rem 0 0;
}
.own-tag-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0.625rem 0 0;
}
.own-tag-form input {
  flex: 1 1 220px;
  min-width: 0;
}
.own-tags-suggest {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.375rem;
  margin-top: 0.5rem;
}
.own-tags-suggest:empty {
  margin-top: 0;
}

/* Il "?" della riservatezza: tooltip .has-tip ancorato a sinistra (sta vicino
   al bordo sinistro del pannello: ancorato a destra finiva tagliato). */
.rec-conf .has-tip::after {
  left: 0;
  right: auto;
}

/* 4a: una sola frase piccola quando la scheda campione non c'e' ancora. */
.sheet-empty {
  font-size: 0.8125rem;
  margin-top: 0.5rem;
}

/* ===== IMPORT PORTAFOGLIO (wizard in Nuova formula) ========================
   Tre passi, uno visibile alla volta. Riusa i mattoni esistenti (panel,
   sheet-warn, pc-actions, tag, btn); qui c'e' solo cio' che e' suo. */
.imp-steps {
  display: flex;
  gap: 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}
.imp-steps li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}
.imp-steps li b {
  display: inline-grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
}
.imp-steps li.on {
  color: var(--ink);
  font-weight: 500;
}
.imp-steps li.on b {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--card);
}
.imp-steps li.done b {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.imp-drop {
  border: 2px dashed var(--line);
  border-radius: 10px;
  background: var(--card);
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 150ms var(--ease-standard), background-color 150ms var(--ease-standard);
}
.imp-drop:hover,
.imp-drop:focus-visible,
.imp-drop.over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.imp-drop strong {
  display: block;
  font-size: 0.9375rem;
}
.imp-drop .hint {
  margin: 0.375rem auto 0;
  max-width: 42rem;
}
.imp-files {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-top: 0.75rem;
}
.imp-file {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  flex-wrap: wrap;
  font-size: 0.8125rem;
}
.imp-file-name {
  font-family: var(--font-mono);
  font-size: 0.75rem;
}
.imp-file-status {
  color: var(--muted);
}
.imp-file.error .imp-file-status {
  color: var(--block);
}
.imp-file.ok .imp-file-status {
  color: var(--note);
}
.imp-h3 {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.9375rem;
}
.imp-batches {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.imp-batch {
  display: flex;
  align-items: center;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 0.625rem 1rem;
}
.imp-batch-main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.imp-batch-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.imp-batch-meta {
  font-size: 0.75rem;
}
.imp-batch .btn {
  flex: none;
}
.imp-revhead {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}
.imp-revhead .imp-h3 {
  margin: 0;
  overflow-wrap: anywhere;
}
.imp-back {
  font: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  margin-bottom: 0;
}
.imp-progress {
  margin: 0.75rem 0 0.25rem;
  font-size: 0.8125rem;
  font-weight: 500;
}
.imp-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-bottom: 0.75rem;
}
.imp-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--signal);
  border-radius: 999px;
  transition: width 240ms var(--ease-standard);
}
.imp-bulkrow {
  margin: 0 0 0.75rem;
}
.imp-cands + .imp-bulkrow,
.imp-cands ~ .imp-bulkrow {
  margin-top: 0.75rem;
}
.imp-bulknote {
  margin: 0 0 0.75rem;
}
.imp-cands {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}
.imp-cand {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 0.75rem 1rem;
}
.imp-cand.approved {
  border-left: 3px solid var(--ok);
}
.imp-cand.rejected {
  opacity: 0.66;
}
.imp-cand-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.imp-code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}
.imp-cand-name {
  font-weight: 500;
  overflow-wrap: anywhere;
}
.imp-cand-name.muted {
  color: var(--muted);
  font-style: italic;
  font-weight: 400;
}
.imp-st {
  margin-left: auto;
}
.imp-st.pending {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 40%, var(--line));
}
.imp-st.approved {
  color: var(--note);
  background: var(--note-soft);
  border-color: color-mix(in srgb, var(--note) 40%, var(--line));
}
.imp-st.rejected,
.imp-st.merged {
  color: var(--muted);
  background: var(--surface-2);
  border-color: var(--line);
}
.imp-conf.hi {
  color: var(--note);
  background: var(--note-soft);
  border-color: color-mix(in srgb, var(--note) 40%, var(--line));
}
.imp-conf.mid {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 40%, var(--line));
}
.imp-conf.lo {
  color: var(--block);
  background: var(--block-soft);
  border-color: color-mix(in srgb, var(--block) 40%, var(--line));
}
.imp-inci {
  margin: 0.5rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  overflow-wrap: anywhere;
}
.imp-noinci {
  margin: 0.5rem 0 0;
}
.imp-toggle {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--accent);
  text-decoration: underline;
}
.imp-cand-meta {
  margin: 0.375rem 0 0;
  font-size: 0.75rem;
}
.imp-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.625rem;
}
.imp-rejbtn:hover:not([disabled]) {
  color: var(--block);
  border-color: color-mix(in srgb, var(--block) 40%, var(--line));
}
.imp-openlink {
  font-size: 0.8125rem;
}
.imp-edit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.625rem 1rem;
  margin-top: 0.625rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.imp-edit label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.imp-edit label.wide,
.imp-edit .pc-actions {
  grid-column: 1 / -1;
}
.imp-edit textarea {
  font-family: var(--font-mono);
  font-size: 0.75rem;
}
.imp-dupbox,
.imp-confirm {
  margin-top: 0.625rem;
}
.imp-dupbox .pc-hit a {
  color: inherit;
}
.imp-similar {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
}
.imp-cand .formerr,
.imp-cand .sheet-status {
  margin: 0.5rem 0 0;
}
.imp-done {
  text-align: center;
  padding: 1.5rem 0 0.5rem;
}
.imp-done-badge {
  margin: 0 auto 0.75rem;
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1.5rem;
}
.imp-done .imp-h3 {
  margin: 0 0 0.375rem;
}
.imp-done-line {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 0 0 1rem;
}
.imp-done .pc-actions {
  justify-content: center;
}
@media (max-width: 640px) {
  .imp-edit {
    grid-template-columns: minmax(0, 1fr);
  }
  .imp-batch {
    flex-wrap: wrap;
  }
  .imp-st {
    margin-left: 0;
  }
  .imp-drop {
    padding: 1rem 0.75rem;
  }
}

/* ---------- occhiello password (feedback primo accesso live) ---------- */
.pwwrap { position: relative; display: block; }
.pwwrap input { width: 100%; padding-right: 2.6rem; }
.pwtoggle {
  position: absolute; right: 0.35rem; top: 50%; transform: translateY(-50%);
  border: 0; background: none; cursor: pointer; font-size: 1rem;
  line-height: 1; padding: 0.35rem; border-radius: 6px;
  opacity: 0.55; filter: grayscale(1);
}
.pwtoggle:hover, .pwtoggle:focus-visible { opacity: 1; }
.pwtoggle.on { opacity: 1; filter: none; }
.pwtoggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
