/* =====================================================================
   CosmoChem — design system
   Identità: inchiostro blu (struttura) + rosa fenolftaleina (accento).
   Un solo file, nessuna dipendenza esterna: funziona anche senza accesso a internet.
   ===================================================================== */

:root {
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;

  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --surface-3: #eef1f6;
  --line: #e2e6ee;
  --line-strong: #c9d0dd;
  --ink: #111a2c;
  --ink-2: #42506b;
  --ink-3: #75819a;
  --on-primary: #ffffff;

  /* Colore base dell'azienda: Teal (come nel vecchio applicativo) */
  --primary: #008080;
  --primary-hover: #006767;
  --primary-soft: #dff1f0;
  --primary-ink: #005a5a;
  --accent: #008080;
  --accent-soft: #dff1f0;
  --accent-on-dark: #3cbcb6;
  --top-bg: #008080; --top-ink: #ffffff; --top-ink-2: rgba(255,255,255,.78); --top-line: #006767; --top-hover: rgba(255,255,255,.16);
  --brand-bg: #008080; --brand-i: #a6ebe6;

  --ok: #14805a;      --ok-soft: #e1f3ea;
  --warn: #a8690c;    --warn-soft: #fcf0d6;
  --bad: #c0392b;     --bad-soft: #fbe6e3;
  --info: #2468a8;    --info-soft: #e3eefa;

  --side-bg: #0f1830;
  --side-ink: #b9c3de;
  --side-ink-strong: #ffffff;
  --side-line: rgba(255,255,255,.08);
  --side-hover: rgba(255,255,255,.06);
  --side-active: rgba(255,255,255,.11);

  --radius-s: 6px; --radius: 10px; --radius-l: 16px;
  --shadow-1: 0 1px 2px rgba(17,26,44,.06), 0 1px 1px rgba(17,26,44,.04);
  --shadow-2: 0 6px 20px rgba(17,26,44,.10), 0 2px 6px rgba(17,26,44,.06);
  --shadow-3: 0 24px 60px rgba(17,26,44,.22), 0 4px 14px rgba(17,26,44,.12);
  --focus: 0 0 0 3px rgba(0,118,118,.30);

  --side-w: 264px; --side-w-min: 76px; --top-h: 60px;
  --ease: cubic-bezier(.2,.7,.2,1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b101d; --surface: #131a2b; --surface-2: #182036; --surface-3: #1e2740;
  --line: #243049; --line-strong: #33425f;
  --ink: #e8ecf6; --ink-2: #b0bad2; --ink-3: #7f8cab;
  --on-primary: #0b101d;
  --primary: #3cbcb6; --primary-hover: #66d0cb; --primary-soft: #0f3a3b; --primary-ink: #a6ebe6;
  --accent: #3cbcb6; --accent-soft: #0f3a3b;
  --top-bg: color-mix(in srgb, var(--bg) 82%, transparent); --top-ink: var(--ink); --top-ink-2: var(--ink-3); --top-line: var(--line); --top-hover: var(--surface-3);
  --brand-bg: transparent; --brand-i: #3cbcb6;
  --ok: #4fd1a1; --ok-soft: #12332a; --warn: #f2b84b; --warn-soft: #3a2c10; --bad: #ff8a7a; --bad-soft: #3d1c19; --info: #7fb6ee; --info-soft: #16304a;
  --side-bg: #080c17; --side-line: rgba(255,255,255,.07);
  --shadow-1: 0 1px 2px rgba(0,0,0,.4); --shadow-2: 0 8px 24px rgba(0,0,0,.45); --shadow-3: 0 28px 70px rgba(0,0,0,.6);
  --focus: 0 0 0 3px rgba(60,188,182,.38);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0b101d; --surface: #131a2b; --surface-2: #182036; --surface-3: #1e2740;
    --line: #243049; --line-strong: #33425f;
    --ink: #e8ecf6; --ink-2: #b0bad2; --ink-3: #7f8cab;
    --on-primary: #0b101d;
    --primary: #3cbcb6; --primary-hover: #66d0cb; --primary-soft: #0f3a3b; --primary-ink: #a6ebe6;
    --accent: #3cbcb6; --accent-soft: #0f3a3b;
    --top-bg: color-mix(in srgb, var(--bg) 82%, transparent); --top-ink: var(--ink); --top-ink-2: var(--ink-3); --top-line: var(--line); --top-hover: var(--surface-3);
    --brand-bg: transparent; --brand-i: #3cbcb6;
    --ok: #4fd1a1; --ok-soft: #12332a; --warn: #f2b84b; --warn-soft: #3a2c10; --bad: #ff8a7a; --bad-soft: #3d1c19; --info: #7fb6ee; --info-soft: #16304a;
    --side-bg: #080c17; --side-line: rgba(255,255,255,.07);
    --shadow-1: 0 1px 2px rgba(0,0,0,.4); --shadow-2: 0 8px 24px rgba(0,0,0,.45); --shadow-3: 0 28px 70px rgba(0,0,0,.6);
    --focus: 0 0 0 3px rgba(60,188,182,.38);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 14.5px/1.5 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; letter-spacing: -.012em; line-height: 1.2; color: var(--ink); }
h1 { font-size: 1.6rem; font-weight: 650; } h2 { font-size: 1.15rem; font-weight: 640; } h3 { font-size: 1rem; font-weight: 620; }
h1:focus { outline: none; }
p { margin: 0 0 .75em; }
a { color: var(--primary); text-decoration: none; } a:hover { text-decoration: underline; text-underline-offset: 3px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
small, .small { font-size: .82rem; }
code, .mono { font-family: var(--mono); font-size: .88em; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-s); }
::selection { background: var(--accent-soft); color: var(--ink); }
.muted { color: var(--ink-3); } .ink2 { color: var(--ink-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; } .center { text-align: center; } .right { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.hide { display: none !important; }
[hidden] { display: none !important; }

/* ---------- Layout utilities ---------- */
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack-s { display: flex; flex-direction: column; gap: .5rem; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.cluster-s { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid { display: grid; gap: 1rem; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } .span-full { grid-column: 1 / -1; }
@media (max-width: 1100px) { .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) { .cols-2, .cols-3, .cols-4 { grid-template-columns: minmax(0, 1fr); } .span-2, .span-3 { grid-column: auto; } }

/* ---------- App shell ---------- */
.app { min-height: 100vh; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); transition: grid-template-columns .22s var(--ease); }
:root[data-sidebar="collapsed"] .app { grid-template-columns: var(--side-w-min) minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; background: var(--side-bg); color: var(--side-ink);
  display: flex; flex-direction: column; z-index: 40; overflow: hidden;
}
.brand { display: flex; align-items: center; gap: .75rem; padding: 1rem 1.15rem; height: var(--top-h); background: var(--brand-bg); border-bottom: 1px solid var(--side-line); color: var(--side-ink-strong); text-decoration: none !important; }
.brand-mark { flex: none; width: 34px; height: 34px; }
.brand-name { font: 650 1.12rem/1 var(--font-display); letter-spacing: -.02em; white-space: nowrap; }
.brand-name i { font-style: normal; color: var(--brand-i); }
.nav { flex: 1; overflow-y: auto; padding: .75rem .65rem 1rem; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
.nav-group { margin-bottom: 1rem; }
.nav-title { padding: .35rem .65rem; font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: rgba(185,195,222,.5); white-space: nowrap; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: .8rem; padding: .56rem .7rem; margin: 1px 0; border-radius: 9px;
  color: var(--side-ink); font-weight: 520; text-decoration: none !important; white-space: nowrap; transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--side-hover); color: var(--side-ink-strong); }
.nav-link.active { background: var(--side-active); color: var(--side-ink-strong); }
.nav-link.active::before { content: ""; position: absolute; left: -.65rem; top: 22%; bottom: 22%; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent-on-dark, var(--accent)); }
.nav-link .icon { flex: none; width: 20px; height: 20px; opacity: .92; }
.nav-link .label { overflow: hidden; text-overflow: ellipsis; color: inherit; font: inherit; }
.nav-count { margin-left: auto; font-size: .72rem; font-weight: 650; padding: 1px 7px; border-radius: 99px; background: var(--accent-on-dark, var(--accent)); color: #04201f; }
.side-foot { border-top: 1px solid var(--side-line); padding: .6rem .65rem; }
:root[data-sidebar="collapsed"] .brand-name, :root[data-sidebar="collapsed"] .nav-title, :root[data-sidebar="collapsed"] .nav-link .label, :root[data-sidebar="collapsed"] .nav-count { display: none; }
:root[data-sidebar="collapsed"] .nav-link { justify-content: center; padding: .65rem; }
:root[data-sidebar="collapsed"] .brand { justify-content: center; padding-inline: 0; }
:root[data-sidebar="collapsed"] .nav-link.active::before { left: -.65rem; }

.main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; gap: .75rem; padding: 0 1.5rem;
  background: var(--top-bg); color: var(--top-ink); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--top-line);
}
.topbar .btn-ghost { color: var(--top-ink); } .topbar .btn-ghost:hover { background: var(--top-hover); color: var(--top-ink); }
.topbar .search-trigger { background: color-mix(in srgb, var(--top-ink) 14%, transparent); border-color: color-mix(in srgb, var(--top-ink) 28%, transparent); color: var(--top-ink-2); }
.topbar .search-trigger:hover { border-color: var(--top-ink-2); }
.topbar .search-trigger kbd { background: transparent; color: var(--top-ink-2); border-color: color-mix(in srgb, var(--top-ink) 35%, transparent); }
.topbar .year-select { color: var(--top-ink-2); }
.topbar .user-btn { color: var(--top-ink); } .topbar .user-btn:hover { background: var(--top-hover); } .topbar .user-btn .u-role { color: var(--top-ink-2); }
.topbar .avatar { background: #fff; color: var(--primary-ink); }
:root[data-theme="dark"] .topbar .avatar { background: var(--primary); color: #04201f; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] .topbar .avatar { background: var(--primary); color: #04201f; } }
.topbar .grow { display: flex; align-items: center; gap: .75rem; }
.content { padding: 1.5rem; width: 100%; max-width: 1600px; margin: 0 auto; flex: 1; }
.search-trigger {
  display: flex; align-items: center; gap: .6rem; min-width: 280px; max-width: 420px; flex: 1 1 280px; padding: .45rem .75rem; border: 1px solid var(--line-strong);
  border-radius: 9px; background: var(--surface); color: var(--ink-3); cursor: pointer; font: inherit; text-align: left;
}
.search-trigger:hover { border-color: var(--ink-3); }
.search-trigger kbd { margin-left: auto; font: 600 .72rem var(--font); padding: 1px 6px; border: 1px solid var(--line-strong); border-radius: 5px; color: var(--ink-3); background: var(--surface-2); }
.year-select { display: flex; align-items: center; gap: .4rem; font-size: .84rem; color: var(--ink-3); }
.year-select select { width: auto; padding: .35rem 1.6rem .35rem .6rem; font-weight: 600; }
.scrim { display: none; }
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr) !important; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, 300px); transform: translateX(-102%); transition: transform .25s var(--ease); box-shadow: var(--shadow-3); }
  .sidebar.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: 0; background: rgba(8,12,23,.55); z-index: 35; backdrop-filter: blur(2px); }
  .topbar { padding: 0 .85rem; } .content { padding: 1rem .85rem 5rem; }
  .search-trigger { min-width: 0; flex: 0 0 auto; padding: .5rem; } .search-trigger span, .search-trigger kbd { display: none; }
  :root[data-sidebar="collapsed"] .brand-name, :root[data-sidebar="collapsed"] .nav-title, :root[data-sidebar="collapsed"] .nav-link .label { display: initial; }
  :root[data-sidebar="collapsed"] .nav-link { justify-content: flex-start; padding: .56rem .7rem; }
  .year-select > span { display: none; }
}

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head .titles { min-width: 0; }
.page-head .sub { color: var(--ink-3); margin-top: .25rem; }
.crumbs { display: flex; gap: .4rem; align-items: center; font-size: .82rem; color: var(--ink-3); margin-bottom: .35rem; flex-wrap: wrap; }
.crumbs a { color: var(--ink-3); } .crumbs a:hover { color: var(--primary); }
.crumbs .sep { opacity: .5; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .52rem .95rem; font: 600 .9rem/1.2 var(--font);
  border-radius: 9px; border: 1px solid transparent; cursor: pointer; text-decoration: none !important; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; user-select: none;
}
.btn .icon { width: 18px; height: 18px; flex: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-1); } .btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); box-shadow: var(--shadow-1); } .btn-secondary:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn-ghost { background: transparent; color: var(--ink-2); } .btn-ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn-danger { background: var(--bad); color: #fff; } .btn-danger:hover { filter: brightness(.92); }
.btn-soft { background: var(--primary-soft); color: var(--primary-ink); } .btn-soft:hover { filter: brightness(.97); }
.btn-accent { background: var(--accent); color: #fff; } .btn-accent:hover { filter: brightness(.94); }
.btn-sm { padding: .32rem .62rem; font-size: .82rem; border-radius: 8px; } .btn-sm .icon { width: 16px; height: 16px; }
.btn-lg { padding: .72rem 1.3rem; font-size: 1rem; }
.btn-icon { padding: .45rem; aspect-ratio: 1; } .btn-icon.btn-sm { padding: .3rem; }
.btn-block { width: 100%; }
.btn .spinner { width: 16px; height: 16px; border-width: 2px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field > label, .label { font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: .78rem; color: var(--ink-3); }
.field .err { font-size: .8rem; color: var(--bad); font-weight: 520; }
.req::after { content: " *"; color: var(--accent); }
.input, .select, .textarea, input:not([type]), input[type="text"], input[type="tel"], input[type="url"], input[type="time"], input[type="search"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="datetime-local"], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 9px; padding: .52rem .7rem;
  transition: border-color .15s, box-shadow .15s; min-height: 38px;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.45; }
.input:hover, .select:hover, input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
input:disabled, select:disabled, textarea:disabled, input[readonly] { background: var(--surface-3); color: var(--ink-2); cursor: not-allowed; }
select, .select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%2375819a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7rem center; padding-right: 2rem; }
input.invalid, .modified.invalid, .invalid { border-color: var(--bad) !important; }
.validation-message { color: var(--bad); font-size: .8rem; margin-top: .2rem; }
.validation-errors { color: var(--bad); background: var(--bad-soft); border-radius: 9px; padding: .6rem .9rem; margin: 0 0 1rem; list-style: none; font-size: .88rem; }
.validation-errors li + li { margin-top: .2rem; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--primary); cursor: pointer; flex: none; }
.check { display: inline-flex; align-items: center; gap: .55rem; cursor: pointer; font-weight: 500; color: var(--ink); }
.switch { position: relative; display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; font-weight: 520; }
.switch input { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; min-height: 0; border-radius: 99px; background: var(--line-strong); border: 0; position: relative; transition: background .18s; padding: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .18s var(--ease); }
.switch input:checked { background: var(--primary); } .switch input:checked::after { transform: translateX(16px); }
.input-affix { position: relative; } .input-affix > .affix { position: absolute; right: .7rem; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-size: .84rem; pointer-events: none; }
.input-affix > input { padding-right: 2.6rem; }
.input-icon { position: relative; } .input-icon > .icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--ink-3); pointer-events: none; }
.input-icon > input { padding-left: 2.3rem; }
.form-grid { display: grid; gap: 1rem 1.1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-grid.f2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form-grid.f3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .form-grid.f4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 760px) { .form-grid.f2, .form-grid.f3, .form-grid.f4 { grid-template-columns: minmax(0, 1fr); } }
.form-actions { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; padding-top: .5rem; }
.sticky-actions { position: sticky; bottom: 0; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: .75rem 1.5rem; margin: 1.5rem -1.5rem -1.5rem; z-index: 10; }
@media (max-width: 900px) { .sticky-actions { margin: 1.5rem -.85rem -5rem; padding: .75rem .85rem; } }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); box-shadow: var(--shadow-1); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 1rem; }
.card-body { padding: 1.25rem; } .card-body.flush { padding: 0; }
.card-foot { padding: .85rem 1.25rem; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius-l) var(--radius-l); }
.card.tight .card-body { padding: 1rem; }
.callout { display: flex; gap: .75rem; padding: .85rem 1rem; border-radius: var(--radius); border: 1px solid; font-size: .9rem; }
.callout .icon { flex: none; width: 20px; height: 20px; margin-top: 1px; }
.callout.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); color: var(--ink); } .callout.info .icon { color: var(--info); }
.callout.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); } .callout.warn .icon { color: var(--warn); }
.callout.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); } .callout.bad .icon { color: var(--bad); }
.callout.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); } .callout.ok .icon { color: var(--ok); }
.callout ul { margin: .3rem 0 0; padding-left: 1.1rem; }

/* ---------- KPI ---------- */
.kpi { position: relative; padding: 1.1rem 1.25rem; display: flex; flex-direction: column; gap: .35rem; overflow: hidden; text-decoration: none !important; color: inherit; transition: box-shadow .18s, transform .18s, border-color .18s; }
a.kpi:hover { box-shadow: var(--shadow-2); border-color: var(--line-strong); transform: translateY(-1px); }
.kpi-label { display: flex; align-items: center; gap: .5rem; color: var(--ink-3); font-size: .84rem; font-weight: 560; }
.kpi-label .icon { width: 18px; height: 18px; }
.kpi-value { font: 660 1.9rem/1.1 var(--font-display); letter-spacing: -.025em; }
.kpi-value small { font-size: .9rem; font-weight: 560; color: var(--ink-3); margin-left: .25rem; letter-spacing: 0; }
.kpi-note { font-size: .82rem; color: var(--ink-3); }
.kpi.warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); } .kpi.bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.kpi.bad .kpi-value { color: var(--bad); } .kpi.warn .kpi-value { color: var(--warn); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.table th {
  position: sticky; top: 0; background: var(--surface-2); text-align: left; font-size: .76rem; font-weight: 650; letter-spacing: .03em; text-transform: uppercase;
  color: var(--ink-3); padding: .65rem .9rem; border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none;
}
.table th.num, .table td.num { text-align: right; }
.table th.sortable { cursor: pointer; } .table th.sortable:hover { color: var(--ink); }
.table th .sort { display: inline-block; width: 12px; margin-left: 4px; opacity: .35; } .table th.sorted .sort { opacity: 1; color: var(--accent); }
.table td { padding: .65rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.row-bad td:first-child { box-shadow: inset 3px 0 0 var(--bad); } .table tr.row-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); } .table tr.row-off { opacity: .6; }
.table .cell-main { font-weight: 600; color: var(--ink); } .table .cell-sub { font-size: .8rem; color: var(--ink-3); }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.table tfoot td { background: var(--surface-2); font-weight: 650; border-top: 1px solid var(--line); border-bottom: 0; }
.table.compact td { padding: .4rem .7rem; } .table.compact th { padding: .5rem .7rem; }
.table input, .table select { min-height: 34px; padding: .32rem .55rem; }
.table td.edit { padding: .3rem .5rem; }
.grid-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--line); }
.grid-toolbar .search { flex: 1 1 240px; max-width: 420px; }
.grid-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 1.1rem; border-top: 1px solid var(--line); flex-wrap: wrap; font-size: .85rem; color: var(--ink-3); }
.pager { display: flex; gap: .25rem; align-items: center; }
.pager .btn { min-width: 34px; }
.pager .btn[aria-current="page"] { background: var(--primary); color: var(--on-primary); }
.grid-loading { position: relative; opacity: .55; pointer-events: none; transition: opacity .15s; }

@media (max-width: 760px) {
  .table.stackable thead { display: none; }
  .table.stackable, .table.stackable tbody, .table.stackable tr, .table.stackable td { display: block; width: 100%; }
  .table.stackable tr { padding: .85rem 1rem; border-bottom: 1px solid var(--line); }
  .table.stackable tbody tr:hover { background: transparent; }
  .table.stackable td { border: 0; padding: .18rem 0; display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; text-align: right; }
  .table.stackable td::before { content: attr(data-label); color: var(--ink-3); font-size: .78rem; font-weight: 600; text-align: left; flex: none; }
  .table.stackable td.cell-title { font-size: 1rem; justify-content: flex-start; text-align: left; padding-bottom: .35rem; }
  .table.stackable td.cell-title::before, .table.stackable td[data-label=""]::before { display: none; }
  .table.stackable td.actions { justify-content: flex-end; width: 100%; padding-top: .5rem; }
  .table.stackable td.hide-sm { display: none; }
  .table.stackable td.num { text-align: right; }
}

/* ---------- Badges, chips, tabs ---------- */
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .12rem .55rem; border-radius: 99px; font-size: .76rem; font-weight: 640; white-space: nowrap; background: var(--surface-3); color: var(--ink-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); } .badge.info { background: var(--info-soft); color: var(--info); }
.badge.primary { background: var(--primary-soft); color: var(--primary-ink); } .badge.accent { background: var(--accent-soft); color: var(--accent); }
.chip { display: inline-flex; align-items: center; gap: .4rem; padding: .2rem .65rem; border-radius: 99px; background: var(--surface-3); font-size: .82rem; font-weight: 540; color: var(--ink-2); }
.chip button { all: unset; cursor: pointer; display: inline-flex; opacity: .6; } .chip button:hover { opacity: 1; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; margin-bottom: 1.25rem; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: .7rem 1rem; border: 0; background: none; font: 600 .92rem var(--font); color: var(--ink-3); cursor: pointer; position: relative; white-space: nowrap; display: inline-flex; align-items: center; gap: .5rem; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: .6rem; right: .6rem; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); }
.tab .badge { font-size: .7rem; padding: 0 .45rem; }
.seg { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 10px; gap: 2px; }
.seg button { border: 0; background: none; padding: .35rem .8rem; border-radius: 8px; font: 600 .85rem var(--font); color: var(--ink-2); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* ---------- Definition lists ---------- */
.dl { display: grid; grid-template-columns: minmax(130px, 220px) 1fr; gap: .65rem 1.25rem; margin: 0; }
.dl dt { color: var(--ink-3); font-size: .85rem; font-weight: 560; } .dl dd { margin: 0; font-weight: 520; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 560px) { .dl { grid-template-columns: 1fr; gap: .1rem; } .dl dd { margin-bottom: .6rem; } }
.stat-row { display: flex; gap: 2rem; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; } .stat .v { font: 650 1.25rem var(--font-display); } .stat .l { font-size: .8rem; color: var(--ink-3); }

/* ---------- Composizione formula (elemento firma) ---------- */
.comp { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--surface-3); gap: 2px; }
.comp > i { display: block; height: 100%; background: var(--c); min-width: 3px; transition: width .35s var(--ease); }
.comp.lg { height: 22px; border-radius: 8px; }
.comp.lg > i { position: relative; }
.comp-legend { display: flex; flex-wrap: wrap; gap: .35rem 1rem; margin-top: .6rem; font-size: .82rem; color: var(--ink-2); }
.comp-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.comp-legend span::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.gauge { display: flex; align-items: center; gap: .75rem; }
.gauge-track { flex: 1; height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.gauge-fill { height: 100%; border-radius: 99px; background: var(--accent); transition: width .3s var(--ease), background .3s; }
.gauge.full .gauge-fill { background: var(--ok); } .gauge.over .gauge-fill { background: var(--bad); }
.gauge-val { font: 650 .95rem var(--font-display); min-width: 4.8rem; text-align: right; }
.gauge.full .gauge-val { color: var(--ok); } .gauge.over .gauge-val { color: var(--bad); }
.progress { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; min-width: 70px; }
.progress > i { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.progress.ok > i { background: var(--ok); } .progress.warn > i { background: var(--warn); }

/* ---------- Modal, drawer, toast ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(8,12,23,.55); backdrop-filter: blur(3px); animation: fade .15s ease-out; }
.modal { background: var(--surface); border-radius: var(--radius-l); box-shadow: var(--shadow-3); width: 100%; max-width: 560px; max-height: calc(100vh - 2rem); display: flex; flex-direction: column; animation: pop .2s var(--ease); border: 1px solid var(--line); }
.modal.lg { max-width: 820px; } .modal.xl { max-width: 1100px; } .modal.sm { max-width: 420px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.35rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 1.1rem; }
.modal-body { padding: 1.35rem; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: .6rem; padding: .9rem 1.35rem; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius-l) var(--radius-l); flex-wrap: wrap; }
.overlay.drawer { justify-content: flex-end; padding: 0; align-items: stretch; }
.overlay.drawer .modal { max-width: 560px; height: 100%; max-height: none; border-radius: var(--radius-l) 0 0 var(--radius-l); animation: slide .25s var(--ease); }
@media (max-width: 640px) { .overlay { padding: 0; align-items: flex-end; } .modal { max-width: none; border-radius: var(--radius-l) var(--radius-l) 0 0; max-height: 92vh; animation: sheet .25s var(--ease); } .overlay.drawer .modal { border-radius: var(--radius-l) var(--radius-l) 0 0; height: auto; max-height: 92vh; } }
.confirm-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; } .confirm-icon.danger { background: var(--bad-soft); color: var(--bad); }
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 200; display: flex; flex-direction: column; gap: .6rem; width: min(400px, calc(100vw - 2rem)); }
.toast { display: flex; gap: .75rem; padding: .85rem 1rem; background: var(--surface); border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--radius); box-shadow: var(--shadow-2); animation: toast .28s var(--ease); }
.toast .t-title { font-weight: 650; } .toast .t-text { color: var(--ink-2); font-size: .9rem; overflow-wrap: anywhere; }
.toast.ok { border-left-color: var(--ok); } .toast.bad { border-left-color: var(--bad); } .toast.warn { border-left-color: var(--warn); } .toast.info { border-left-color: var(--info); }
.toast .icon { width: 20px; height: 20px; flex: none; margin-top: 2px; } .toast.ok .icon { color: var(--ok); } .toast.bad .icon { color: var(--bad); } .toast.warn .icon { color: var(--warn); } .toast.info .icon { color: var(--info); }
.toast .close { margin-left: auto; align-self: flex-start; }
@keyframes fade { from { opacity: 0 } } @keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98) } }
@keyframes slide { from { transform: translateX(40px); opacity: 0 } } @keyframes sheet { from { transform: translateY(40px); opacity: 0 } }
@keyframes toast { from { opacity: 0; transform: translateY(12px) scale(.98) } }

/* ---------- Menu, autocomplete, command palette ---------- */
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-2); padding: .35rem; z-index: 60; animation: pop .15s var(--ease); }
.menu.left { right: auto; left: 0; }
.menu a, .menu button { display: flex; align-items: center; gap: .65rem; width: 100%; padding: .5rem .7rem; border-radius: 7px; border: 0; background: none; font: 520 .9rem var(--font); color: var(--ink); cursor: pointer; text-align: left; text-decoration: none !important; }
.menu a:hover, .menu button:hover { background: var(--surface-3); } .menu .icon { width: 18px; height: 18px; color: var(--ink-3); }
.menu hr { margin: .3rem 0; } .menu .menu-head { padding: .55rem .7rem; } .menu .danger { color: var(--bad); }
.menu-backdrop { position: fixed; inset: 0; z-index: 55; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font: 650 .8rem var(--font); flex: none; letter-spacing: .02em; }
.user-btn { display: flex; align-items: center; gap: .6rem; background: none; border: 0; cursor: pointer; padding: .25rem .4rem .25rem .25rem; border-radius: 99px; font: inherit; color: var(--ink); }
.user-btn:hover { background: var(--surface-3); } .user-btn .u-name { font-weight: 600; font-size: .88rem; line-height: 1.15; text-align: left; } .user-btn .u-role { font-size: .74rem; color: var(--ink-3); }
@media (max-width: 760px) { .user-btn .u-meta { display: none; } }

.ac { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow-2); z-index: 70; max-height: 300px; overflow-y: auto; padding: .3rem; min-width: 260px; }
.ac-item { display: flex; flex-direction: column; padding: .45rem .65rem; border-radius: 7px; cursor: pointer; }
.ac-item.active, .ac-item:hover { background: var(--primary-soft); }
.ac-item .a { font-weight: 600; } .ac-item .b { font-size: .8rem; color: var(--ink-3); }
.ac-empty { padding: .7rem; color: var(--ink-3); font-size: .88rem; }
.ac-clear { position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); }

.palette { width: min(640px, 100%); max-height: 70vh; }
.overlay.top { align-items: flex-start; padding-top: 12vh; }
.palette-input { display: flex; align-items: center; gap: .75rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); }
.palette-input input { border: 0; box-shadow: none !important; font-size: 1.05rem; padding: 0; background: transparent; min-height: 0; }
.palette-list { overflow-y: auto; padding: .4rem; }
.palette-group { padding: .5rem .7rem .2rem; font-size: .72rem; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
.palette-item { display: flex; align-items: center; gap: .8rem; padding: .55rem .7rem; border-radius: 9px; cursor: pointer; color: var(--ink); text-decoration: none !important; }
.palette-item.active { background: var(--primary-soft); }
.palette-item .icon { width: 18px; height: 18px; color: var(--ink-3); flex: none; } .palette-item .sub { margin-left: auto; font-size: .8rem; color: var(--ink-3); }

/* ---------- Stati vuoti, skeleton, spinner ---------- */
.empty { text-align: center; padding: 3rem 1.5rem; display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.empty-icon { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); margin-bottom: .4rem; }
.empty-icon .icon { width: 30px; height: 30px; }
.empty h3 { font-size: 1.08rem; } .empty p { color: var(--ink-3); max-width: 44ch; margin: 0 0 .6rem; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line-strong); border-top-color: var(--primary); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }
.boot-inline { display: grid; place-items: center; min-height: 40vh; }
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 6px; height: 1em; }
@keyframes shimmer { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } }
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 5; transition: opacity .25s; }
.boot.done { opacity: 0; pointer-events: none; }
.boot-mark { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--line-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }

/* ---------- Grafici ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font: 500 14px var(--font); fill: var(--ink-3); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .bar { fill: var(--primary); transition: opacity .15s; } .chart .bar.alt { fill: var(--accent); }
.chart .bar:hover { opacity: .8; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent); opacity: .12; }
.chart .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart .val { fill: var(--ink-2); font-weight: 650; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--primary); margin-right: .4rem; }

/* ---------- Pagine di accesso ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--bg); }
.auth-brand { position: relative; background: var(--side-bg); color: var(--side-ink); padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; }
.auth-brand::before { content: ""; position: absolute; width: 520px; height: 520px; right: -160px; bottom: -180px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, rgba(0,160,155,.55), rgba(0,160,155,0) 68%); }
.auth-brand::after { content: ""; position: absolute; width: 340px; height: 340px; left: -120px; top: -100px; border-radius: 50%; background: radial-gradient(circle, rgba(0,128,128,.28), rgba(0,128,128,0) 70%); }
.auth-brand > * { position: relative; z-index: 1; }
.auth-brand .brand { background: transparent; }
.auth-brand h2 { color: #fff; font-size: clamp(1.8rem, 3vw, 2.5rem); font-weight: 650; max-width: 14ch; line-height: 1.12; }
.auth-brand p { color: var(--side-ink); max-width: 38ch; font-size: 1.02rem; }
.auth-form { display: grid; place-items: center; padding: 2rem 1.25rem; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { margin-bottom: .35rem; }
@media (max-width: 860px) { .auth { grid-template-columns: minmax(0, 1fr); } .auth-brand { display: none; } }

/* ---------- Stampa ---------- */
.print-bar { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.print-stage { background: var(--surface-3); padding: 1.5rem 1rem 3rem; min-height: 100vh; }
.sheet { background: #fff; color: #111; width: 210mm; min-height: 297mm; margin: 0 auto 1.5rem; padding: 14mm 14mm 16mm; box-shadow: var(--shadow-2); font-size: 10.5pt; line-height: 1.4; font-family: "Segoe UI", Arial, sans-serif; display: flex; flex-direction: column; }
.sheet h1 { font-size: 17pt; color: #111; } .sheet h2 { font-size: 11.5pt; color: #111; margin: 1.1em 0 .4em; }
.sheet .sh-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #111; padding-bottom: 8px; margin-bottom: 12px; gap: 12px; }
.sheet .sh-brand { font: 700 11pt "Segoe UI", Arial; letter-spacing: .01em; } .sheet .sh-addr { font-size: 8.5pt; color: #555; }
.sheet .sh-company { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; } .sheet .sh-logo { display: block; height: 52px; width: auto; max-width: 160px; object-fit: contain; margin-bottom: 8px; }
.sheet .sh-foot { margin-top: auto; padding-top: 18px; text-align: center; font: 700 8pt Arial, sans-serif; line-height: 1.35; color: #000; }
.sheet table { width: 100%; border-collapse: collapse; margin: 6px 0 10px; }
.sheet th { text-align: left; font-size: 8.5pt; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1.5px solid #111; padding: 4px 6px; background: #f1f1f1; color: #111; position: static; }
.sheet td { padding: 4px 6px; border-bottom: 1px solid #ccc; vertical-align: top; color: #111; }
.sheet td.num, .sheet th.num { text-align: right; }
.sheet table.dense { table-layout: fixed; font-size: 8.5pt; } .sheet table.dense th, .sheet table.dense td { padding: 3px 4px; overflow-wrap: anywhere; word-break: break-word; hyphens: auto; } .sheet table.dense th { font-size: 7.5pt; }
.sheet .meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px 12px; margin: 8px 0 12px; }
.sheet .meta div span { display: block; font-size: 8pt; text-transform: uppercase; color: #555; letter-spacing: .04em; } .sheet .meta div b { font-size: 10.5pt; }
.sheet .box { border: 1px solid #999; border-radius: 4px; padding: 6px 8px; margin: 8px 0; }
.sheet .sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 26px; } .sheet .sign div { border-top: 1px solid #111; padding-top: 4px; font-size: 8.5pt; color: #444; }
.sheet .lot-sub td { border-bottom: 1px dotted #bbb; color: #333; font-size: 9.5pt; }
.sheet .short { color: #b00020; font-weight: 700; }
.sheet .stamp { display: inline-block; border: 2px solid #b00020; color: #b00020; font-weight: 800; letter-spacing: .08em; padding: 2px 8px; transform: rotate(-3deg); }
.labels { display: flex; flex-wrap: wrap; gap: 6mm; justify-content: flex-start; }
.label-card { width: 90mm; height: 55mm; border: 1px solid #111; border-radius: 3mm; padding: 3mm; display: grid; grid-template-columns: 1fr 26mm; gap: 3mm; background: #fff; color: #111; page-break-inside: avoid; font-family: "Segoe UI", Arial, sans-serif; }
.label-card .lc-code { font: 800 16pt var(--font-display); line-height: 1; } .label-card .lc-name { font-weight: 650; font-size: 10.5pt; line-height: 1.2; margin: 1mm 0 2mm; }
.label-card dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 0 2mm; font-size: 8.5pt; } .label-card dt { color: #555; } .label-card dd { margin: 0; font-weight: 650; }
.label-card .qr svg { width: 26mm; height: 26mm; display: block; } .label-card .lc-foot { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: 8pt; border-top: 1px solid #999; padding-top: 1mm; }
.label-card .lc-chip { border: 1px solid #111; border-radius: 2mm; padding: 0 2mm; font-weight: 700; font-size: 8pt; }
.label-card .lc-chip.on { background: #111; color: #fff; }
@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; }
  .sidebar, .topbar, .print-bar, .toasts, .scrim, .boot, #blazor-error-ui, .no-print { display: none !important; }
  .app { display: block !important; } .content { padding: 0 !important; max-width: none !important; }
  .print-stage { background: #fff; padding: 0; min-height: 0; }
  .sheet { box-shadow: none; margin: 0; width: auto; min-height: 0; padding: 12mm 12mm 14mm; }
  .sheet + .sheet { page-break-before: always; }
  .labels { gap: 4mm; padding: 8mm; }
}
@media (max-width: 860px) { .sheet { width: 100%; min-height: 0; padding: 1rem; } .sheet .meta { grid-template-columns: repeat(2, 1fr); } .label-card { width: 100%; } }
@page { margin: 0; }

/* ---------- Pannelli speciali ---------- */
.lot-row { display: flex; align-items: center; gap: .75rem; padding: .55rem 0; border-bottom: 1px solid var(--line); } .lot-row:last-child { border-bottom: 0; }
.timeline { position: relative; padding-left: 1.4rem; } .timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline-item { position: relative; padding: 0 0 1rem; } .timeline-item::before { content: ""; position: absolute; left: -1.4rem; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); }
.step-bar { display: flex; gap: .5rem; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: .55rem; padding: .4rem .85rem .4rem .45rem; border-radius: 99px; background: var(--surface-3); color: var(--ink-3); font-weight: 600; font-size: .86rem; }
.step b { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); font-size: .8rem; }
.step.on { background: var(--primary-soft); color: var(--primary-ink); } .step.on b { background: var(--primary); color: var(--on-primary); }
.step.done b { background: var(--ok); color: #fff; }
.drop { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 1.1rem; text-align: center; color: var(--ink-3); transition: border-color .15s, background .15s; }
.drop:hover { border-color: var(--primary); background: var(--primary-soft); }
.kbd { font: 600 .75rem var(--font); padding: 1px 6px; border: 1px solid var(--line-strong); border-radius: 5px; color: var(--ink-3); background: var(--surface-2); }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
#blazor-error-ui { background: var(--bad); color: #fff; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none; left: 0; padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; } #blazor-error-ui a { color: #fff; text-decoration: underline; margin-left: .75rem; }
.blazor-error-boundary { background: var(--bad-soft); color: var(--bad); padding: 1rem; border-radius: var(--radius); } .blazor-error-boundary::after { content: "Errore nel componente."; }
.pink-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: .4rem; }
.bottom-nav { display: none; }
@media (max-width: 900px) {
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding: .3rem .4rem calc(.3rem + env(safe-area-inset-bottom)); box-shadow: 0 -4px 20px rgba(17,26,44,.08); }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .35rem; border: 0; background: none; font: 600 .68rem var(--font); color: var(--ink-3); border-radius: 10px; text-decoration: none !important; cursor: pointer; }
  .bottom-nav a.active { color: var(--primary); background: var(--primary-soft); }
  .bottom-nav .icon { width: 22px; height: 22px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
.ml { margin-left: .5rem; }

h1:focus, h1:focus-visible, h1[tabindex]:focus { outline: none !important; box-shadow: none !important; border: 0 !important; }

/* ---------- Nuova produzione / stampe ---------- */
.prod-wrap { max-width: 1080px; display: grid; gap: 1.1rem; }
.prod-tipo { justify-self: start; flex-wrap: wrap; }
.prod-tipo button { display: inline-flex; align-items: center; gap: .45rem; padding: .5rem 1rem; }
.prod-tipo .icon { width: 17px; height: 17px; }
.prod-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1.1rem; align-items: stretch; }
@media (max-width: 900px) { .prod-grid { grid-template-columns: minmax(0, 1fr); } }
.prod-card { padding: 1.35rem 1.4rem 1.2rem; display: flex; flex-direction: column; gap: 1.1rem; }
.prod-head { display: flex; gap: .85rem; align-items: center; }
.prod-head h2 { margin: 0; font-size: 1.05rem; }
.prod-head p { margin: .1rem 0 0; font-size: .84rem; color: var(--ink-3); }
.prod-n { flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-ink); font-weight: 700; }
.opt-list { display: grid; gap: .55rem; }
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem .95rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.opt-row:hover { border-color: var(--line-strong); }
.opt-txt { display: grid; gap: .15rem; min-width: 0; }
.opt-txt b { font-weight: 620; }
.opt-txt small { color: var(--ink-3); font-size: .8rem; line-height: 1.35; }
.opt-row.opt-off { opacity: .55; cursor: not-allowed; }
.opt-row.opt-on-warn { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 9%, var(--surface-2)); }
.opt-row .switch { flex: none; }
.prod-note { display: flex; gap: .55rem; align-items: center; font-size: .84rem; color: var(--warn); font-weight: 560; }
.prod-note .icon { width: 17px; height: 17px; flex: none; }
.prod-foot { margin-top: auto; padding-top: .6rem; display: flex; justify-content: flex-end; align-items: center; gap: .75rem; flex-wrap: wrap; }
.btn-lg { padding: .7rem 1.25rem; font-size: .98rem; }

/* ---------- Caricamento file ---------- */
.fd-wrap { display: grid; gap: .65rem; }
.filedrop { position: relative; display: flex; align-items: center; justify-content: center; gap: .9rem; padding: 1.5rem 1rem; text-align: left; cursor: pointer;
  border: 1.5px dashed var(--line-strong); border-radius: 14px; background: var(--surface-2); color: var(--ink-2);
  transition: border-color .15s, background .15s, box-shadow .15s; }
.filedrop.is-compact { padding: .8rem 1rem; }
.filedrop:hover, .filedrop.drag, .filedrop:focus-within { border-color: var(--primary); background: var(--primary-soft); }
.filedrop.drag { box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); }
.filedrop input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; min-height: 0; padding: 0; border: 0; }
.filedrop input[type="file"]::file-selector-button { cursor: pointer; }
.fd-ico { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.filedrop:hover .fd-ico, .filedrop.drag .fd-ico { background: var(--primary); color: var(--on-primary); }
.is-compact .fd-ico { width: 34px; height: 34px; border-radius: 10px; }
.fd-ico .icon { width: 22px; height: 22px; } .is-compact .fd-ico .icon { width: 18px; height: 18px; }
.fd-txt { display: block; font-size: .92rem; line-height: 1.4; }
.fd-txt b { color: var(--ink); font-weight: 620; display: inline; } .fd-txt u { color: var(--primary); text-decoration: none; font-weight: 600; }
.fd-txt small { display: block; color: var(--ink-3); font-size: .78rem; margin-top: .15rem; }
.file-chip { display: flex; align-items: center; gap: .85rem; padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-1); }
.file-chip .fc-ico { flex: none; min-width: 42px; height: 42px; padding: 0 .35rem; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-ink); font: 700 .72rem var(--font); letter-spacing: .04em; }
.file-chip .fc-txt { display: grid; min-width: 0; flex: 1; } .file-chip .fc-txt b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 620; }
.file-chip .fc-txt small { color: var(--ink-3); font-size: .78rem; }
.file-chip.is-new { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }
.file-chip.is-warn { border-color: var(--warn); background: var(--warn-soft); } .file-chip.is-warn .fc-ico { background: transparent; color: var(--warn); }
.file-chip .fc-del:hover { color: var(--bad); }

/* ---------- Rifinitura generale ---------- */
:root { --ring: 0 0 0 3px color-mix(in srgb, var(--primary) 26%, transparent); }
.card { border-radius: 16px; box-shadow: 0 1px 2px rgba(17,26,44,.05), 0 8px 24px -12px rgba(17,26,44,.10); }
:root[data-theme="dark"] .card { box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.card-head { background: linear-gradient(180deg, color-mix(in srgb, var(--surface-2) 70%, transparent), transparent); }
.btn { border-radius: 10px; font-weight: 600; transition: background .15s, box-shadow .15s, transform .08s, border-color .15s, filter .15s; }
.btn-primary { box-shadow: 0 1px 2px rgba(0,60,60,.25), inset 0 1px 0 rgba(255,255,255,.14); }
.btn-primary:hover { box-shadow: 0 4px 12px -4px rgba(0,100,100,.5), inset 0 1px 0 rgba(255,255,255,.14); }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea { border-radius: 10px; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
input[type="checkbox"] { border-radius: 5px; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--primary) 5%, transparent); }
.table th { letter-spacing: .02em; }
.badge, .chip { border-radius: 99px; }
.nav-link { border-radius: 10px; }
.page-head h1 { letter-spacing: -.02em; }
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--ink-3) 45%, transparent) transparent; }

/* ---------- Situazione di magazzino della materia prima ---------- */
.stock { margin: 0 0 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-1); overflow: hidden; }
.stock-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .8rem 1.1rem; border-bottom: 1px solid var(--line); background: var(--primary-soft); }
.stock-head h2 { font-size: .98rem; color: var(--primary-ink); } .stock-head h2 span { font-weight: 500; color: var(--ink-3); margin-left: .4rem; font-size: .84rem; }
.stock-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.stock-cell { padding: .9rem 1.1rem; border-right: 1px solid var(--line); display: grid; align-content: start; gap: .25rem; min-width: 0; }
.stock-cell:last-child { border-right: 0; }
.stock-cell .sl { font-size: .76rem; font-weight: 600; color: var(--ink-3); }
.stock-cell b { font: 650 1.22rem/1.15 var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stock-cell b small { font: 560 .72rem var(--font); color: var(--ink-3); margin-left: .3rem; }
.stock-cell em { font-style: normal; font-size: .72rem; color: var(--ink-3); }
.stock-cell.is-plus b { color: var(--ok); } .stock-cell.is-minus b { color: var(--bad); }
.stock-cell.is-key { background: color-mix(in srgb, var(--primary) 6%, var(--surface)); } .stock-cell.is-key b { font-size: 1.4rem; color: var(--primary-ink); }
.stock-cell.is-bad b { color: var(--bad); } .stock-cell.is-warn b { color: var(--warn); }
@media (max-width: 1180px) { .stock-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } .stock-cell { border-bottom: 1px solid var(--line); } }
@media (max-width: 560px) { .stock-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Aspetto moderno: pagine, schede, tabelle, finestre ---------- */
.err-detail { display: block; max-width: 720px; margin: 0 auto .8rem; padding: .5rem .75rem; border-radius: 8px; background: var(--surface-3); color: var(--ink-2); font: 500 .78rem/1.4 var(--mono); text-align: left; overflow-wrap: anywhere; }
body { background: radial-gradient(1200px 380px at 70% -120px, color-mix(in srgb, var(--primary) 9%, transparent), transparent 70%), var(--bg); background-attachment: fixed; }
.page-head h1 { font-size: clamp(1.5rem, 2.2vw, 1.9rem); font-weight: 700; }
.page-head .sub { font-size: .95rem; }

/* Schede a pillola al posto della sottolineatura */
.tabs { border-bottom: 0; gap: .35rem; padding: .3rem; background: var(--surface-3); border-radius: 14px; width: fit-content; max-width: 100%; margin-bottom: 1.25rem; }
.tab { padding: .5rem .95rem; border-radius: 10px; color: var(--ink-2); transition: background .15s, color .15s, box-shadow .15s; }
.tab:hover { color: var(--ink); background: color-mix(in srgb, var(--surface) 55%, transparent); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--primary-ink); box-shadow: 0 1px 3px rgba(17,26,44,.12); }
.tab[aria-selected="true"]::after { display: none; }

/* Tabelle */
.table th { background: color-mix(in srgb, var(--surface-2) 80%, transparent); color: var(--ink-3); font-size: .74rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; padding-block: .7rem; border-bottom: 1px solid var(--line-strong); }
.table td { padding-block: .8rem; }
.table tbody tr:last-child td { border-bottom: 0; }
.card > .table-wrap, .card > .table { border-radius: 0 0 16px 16px; }

/* Indicatori */
.kpi { border-radius: 16px; transition: box-shadow .18s, transform .18s, border-color .18s; }
a.kpi:hover, .kpi.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); }
.kpi-label .icon { width: 30px; height: 30px; padding: 6px; border-radius: 9px; background: var(--primary-soft); color: var(--primary); box-sizing: border-box; }
.kpi.bad .kpi-label .icon { background: var(--bad-soft); color: var(--bad); } .kpi.warn .kpi-label .icon { background: var(--warn-soft); color: var(--warn); }
.kpi-value { font-size: 1.7rem; white-space: nowrap; }

/* Finestre e notifiche */
.modal-backdrop, .backdrop, .overlay { backdrop-filter: blur(3px); }
.modal { border-radius: 20px; border: 1px solid var(--line); }
.modal-head { padding: 1.2rem 1.5rem; } .modal-body { padding: 1.5rem; } .modal-foot { border-radius: 0 0 20px 20px; }
.toast { border-left-width: 1px; border-radius: 14px; box-shadow: var(--shadow-2); }
.toast.ok .icon, .toast.bad .icon, .toast.warn .icon, .toast.info .icon { padding: 5px; width: 28px; height: 28px; border-radius: 9px; box-sizing: border-box; margin-top: 0; }
.toast.ok .icon { background: var(--ok-soft); } .toast.bad .icon { background: var(--bad-soft); } .toast.warn .icon { background: var(--warn-soft); } .toast.info .icon { background: var(--info-soft); }
.callout { border-radius: 14px; }

/* Barra azioni fissa in fondo ai moduli: sospesa e arrotondata */
.sticky-actions { margin-inline: 0; border: 1px solid var(--line); border-radius: 16px; bottom: .9rem; box-shadow: var(--shadow-2); background: color-mix(in srgb, var(--surface) 92%, transparent); }
a { text-underline-offset: 3px; }
::selection { background: color-mix(in srgb, var(--primary) 28%, transparent); }

/* ---------- Impostazioni ---------- */
.set-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 1.25rem; align-items: start; max-width: 1100px; }
.set-nav { position: sticky; top: 1rem; display: grid; gap: .35rem; padding: .5rem; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-1); }
.set-tab { display: flex; align-items: center; gap: .75rem; width: 100%; text-align: left; padding: .65rem .7rem; border: 0; border-radius: 11px; background: none; color: var(--ink-2); font: inherit; cursor: pointer; transition: background .15s, color .15s; }
.set-tab:hover { background: var(--surface-3); }
.set-tab[aria-selected="true"] { background: var(--primary-soft); color: var(--primary-ink); }
.set-ico { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); }
.set-tab[aria-selected="true"] .set-ico { background: var(--primary); color: var(--on-primary); }
.set-ico .icon { width: 18px; height: 18px; }
.set-lbl { display: grid; min-width: 0; line-height: 1.25; } .set-lbl b { font-weight: 620; } .set-lbl small { color: var(--ink-3); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-tab[aria-selected="true"] .set-lbl small { color: color-mix(in srgb, var(--primary-ink) 70%, transparent); }
.set-body { display: grid; gap: 1.1rem; min-width: 0; padding-bottom: 4.5rem; }
.set-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; } .set-grid .full { grid-column: 1 / -1; }
.chip-ok { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 600; color: var(--primary-ink); background: var(--primary-soft); padding: .2rem .6rem; border-radius: 99px; } .chip-ok .icon { width: 14px; height: 14px; }

.logo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem; }
.logo-tile { display: flex; flex-direction: column; gap: .75rem; padding: .85rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.logo-prev { height: 96px; display: grid; place-items: center; border-radius: 10px; background: #fff; border: 1px solid var(--line); padding: .5rem;
  background-image: linear-gradient(45deg, #f1f3f5 25%, transparent 25%, transparent 75%, #f1f3f5 75%), linear-gradient(45deg, #f1f3f5 25%, transparent 25%, transparent 75%, #f1f3f5 75%); background-size: 14px 14px; background-position: 0 0, 7px 7px; }
.logo-prev { overflow: hidden; display: flex; align-items: center; justify-content: center; } .logo-prev img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.logo-info { display: grid; gap: .15rem; } .logo-info b { font-weight: 620; } .logo-info small { color: var(--ink-3); font-size: .8rem; }
.logo-stato { justify-self: start; margin-top: .25rem; font-size: .72rem; font-weight: 650; padding: .12rem .5rem; border-radius: 99px; background: var(--surface-3); color: var(--ink-3); } .logo-stato.on { background: var(--primary-soft); color: var(--primary-ink); }
.logo-act { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: auto; } .logo-act label { cursor: pointer; }

.sheet-prev { background: #fff; color: #111; border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem 1.25rem; font-family: "Segoe UI", Arial, sans-serif; box-shadow: var(--shadow-1); max-width: 560px; }
.sp-head { display: block; padding-bottom: .8rem; border-bottom: 2px solid #111; }
.sp-head img { height: 46px; width: auto; max-width: 110px; object-fit: contain; } .sp-head img.sp-cert { height: 34px; margin-left: auto; }
.sp-head div { display: grid; gap: .25rem; justify-items: start; min-width: 0; } .sp-head b { font-size: 1rem; } .sp-head small { color: #555; font-size: .78rem; }
.sp-body { display: grid; gap: .5rem; padding: 1rem 0; } .sp-body i { display: block; height: 8px; border-radius: 4px; background: #e6e8eb; } .sp-body i.short { width: 55%; }
.sp-foot { display: grid; gap: .1rem; text-align: center; font-size: .68rem; font-weight: 700; padding-top: .7rem; border-top: 1px solid #ddd; }

.label-prev { display: grid; grid-template-columns: 64px 1fr 1fr 1fr; align-items: stretch; border: 1.5px solid #111; background: #fff; color: #111; max-width: 560px; font-family: Arial, Helvetica, sans-serif; font-size: .8rem; }
.label-prev > * { padding: .5rem .6rem; border-right: 1px solid #111; display: grid; align-content: center; } .label-prev > *:last-child { border-right: 0; }
.label-prev img { width: 100%; height: auto; padding: 0; object-fit: contain; }
.label-prev div:nth-child(2) span { font-size: .68rem; line-height: 1.5; }
.lp-data { text-align: center; } .lp-data small { font-size: .7rem; } .lp-data b { font-size: .8rem; }

.set-savebar { position: sticky; bottom: .9rem; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; max-width: 1100px; margin-top: 1rem; padding: .75rem 1rem; border: 1px solid var(--line-strong); border-radius: 16px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); box-shadow: 0 12px 32px -12px rgba(17,26,44,.35); animation: setbar .22s var(--ease); }
.set-dirty { display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; color: var(--warn); } .set-dirty .icon { width: 18px; height: 18px; }
@keyframes setbar { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .set-savebar { animation: none; } }

@media (max-width: 900px) {
  .set-savebar { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  .set-layout { grid-template-columns: minmax(0, 1fr); }
  .set-nav { position: static; display: flex; overflow-x: auto; gap: .3rem; padding: .35rem; scrollbar-width: none; }
  .set-nav::-webkit-scrollbar { display: none; }
  .set-tab { width: auto; flex: none; padding: .5rem .75rem; } .set-lbl small { display: none; } .set-ico { width: 28px; height: 28px; } .set-ico .icon { width: 16px; height: 16px; }
  .logo-grid { grid-template-columns: minmax(0, 1fr); }
  .logo-tile { flex-direction: row; flex-wrap: wrap; align-items: center; } .logo-prev { width: 120px; height: 72px; flex: none; } .logo-info { flex: 1; min-width: 140px; } .logo-act { width: 100%; }
}
@media (max-width: 560px) {
  .set-grid { grid-template-columns: minmax(0, 1fr); }
  .set-savebar { padding: .65rem .8rem; } .set-savebar .cluster { width: 100%; } .set-savebar .btn { flex: 1; justify-content: center; }
  .label-prev { grid-template-columns: 52px 1fr 1fr; } .label-prev .lp-data:last-child { display: none; }
}
@media print { .set-savebar, .set-nav { display: none; } }

/* ---------- Combo con ricerca ---------- */
.combo { position: relative; }
.combo > input { padding-right: 2rem; cursor: text; text-overflow: ellipsis; }
.combo-arrow { position: absolute; right: .75rem; top: 50%; width: 12px; height: 8px; margin-top: -4px; pointer-events: none; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%2375819a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center; }
.combo-list { min-width: 100%; width: max-content; max-width: min(520px, 92vw); }
.combo-item { flex-direction: row; align-items: baseline; justify-content: space-between; gap: .8rem; }
.combo-item .a { font-weight: 500; } .combo-item.sel .a { color: var(--primary); font-weight: 650; }
.table .combo > input { min-height: 34px; padding: .32rem 2rem .32rem .55rem; }

/* Tag selezionati: più evidenti (colore del tema, bordo, X sempre visibile) */
.chip { background: var(--primary-soft); color: var(--primary-ink); border: 1px solid color-mix(in srgb, var(--primary) 45%, transparent); padding: .3rem .5rem .3rem .8rem; font-size: .86rem; font-weight: 650; line-height: 1.2; }
.chip button { opacity: 1; width: 20px; height: 20px; align-items: center; justify-content: center; border-radius: 50%; background: color-mix(in srgb, var(--primary) 22%, transparent); color: var(--primary-ink); }
.chip button:hover { background: var(--primary); color: #fff; }
.chip button .icon { width: 12px; height: 12px; }

/* ---------- Login: pannello sinistro ---------- */
.auth-brand { background:
    radial-gradient(900px 520px at 100% 100%, rgba(0,170,160,.28), transparent 62%),
    radial-gradient(620px 420px at 0% 0%, rgba(0,128,128,.22), transparent 65%),
    var(--side-bg); gap: 2rem; }
.auth-brand::before { width: auto; height: auto; inset: 0; right: 0; bottom: 0; border-radius: 0; opacity: .5;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='97' viewBox='0 0 56 97'%3E%3Cg fill='none' stroke='%2338b9b2' stroke-opacity='.22' stroke-width='1'%3E%3Cpath d='M28 2 54 17v30L28 62 2 47V17zM28 62v33M2 47-24 62M54 47l26 15'/%3E%3C/g%3E%3C/svg%3E") ;
  -webkit-mask-image: linear-gradient(160deg, transparent 5%, #000 55%, #000); mask-image: linear-gradient(160deg, transparent 5%, #000 55%, #000); }
.auth-brand::after { display: none; }
.auth-hero { display: grid; gap: 1.1rem; align-content: center; }
.auth-hero h2 { max-width: 24ch; font-size: clamp(1.7rem, 2.6vw, 2.3rem); letter-spacing: -.02em; }
.auth-hero > p { max-width: 50ch; }
.trace { list-style: none; margin: .9rem 0 0; padding: 0; display: grid; gap: .55rem; max-width: 440px; position: relative; }
.trace::before { content: ""; position: absolute; left: 1.55rem; top: 1.6rem; bottom: 1.6rem; width: 2px; background: linear-gradient(#38b9b2, rgba(56,185,178,.15)); transform-origin: top; animation: traccia 1.1s .25s var(--ease) both; }
.trace li { position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .85rem; padding: .6rem .9rem .6rem .7rem; border-radius: 14px; background: rgba(255,255,255,.055); border: 1px solid rgba(255,255,255,.09); backdrop-filter: blur(6px); animation: compari .5s var(--ease) both; }
.trace li:nth-child(1) { animation-delay: .1s; } .trace li:nth-child(2) { animation-delay: .3s; } .trace li:nth-child(3) { animation-delay: .5s; } .trace li:nth-child(4) { animation-delay: .7s; }
.trace b { display: block; color: #fff; font-weight: 620; font-size: .95rem; line-height: 1.2; } .trace small { color: var(--side-ink); font-size: .78rem; }
.trace em { font-style: normal; font-weight: 650; font-size: .82rem; color: #bff1ed; font-variant-numeric: tabular-nums; padding: .2rem .55rem; border-radius: 99px; background: rgba(56,185,178,.14); }
.t-ico { width: 2.1rem; height: 2.1rem; border-radius: 50%; display: grid; place-items: center; background: #14304a; border: 1px solid rgba(56,185,178,.55); position: relative; z-index: 1; }
.t-ico svg { width: 1.05rem; height: 1.05rem; fill: none; stroke: #7fe0d9; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.trace li.fine { background: rgba(56,185,178,.16); border-color: rgba(56,185,178,.5); } .trace li.fine .t-ico { background: #0b8f8a; border-color: #7fe0d9; } .trace li.fine .t-ico svg { stroke: #fff; }
@keyframes traccia { from { transform: scaleY(0); } }
@keyframes compari { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { .trace::before, .trace li { animation: none; } }

/* ---------- Tracciabilità ---------- */
.trace-pick-body { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; } .trace-pick-body .grow { flex: 1 1 320px; min-width: 0; }
.trace-kpi { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 900px) { .trace-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); } .trace-kpi .stock-cell { border-bottom: 1px solid var(--line); } }
.trace-bar { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin: 1.1rem 0 .7rem; flex-wrap: wrap; }
.lot-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); overflow: hidden; }
.lot-card.is-expired { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.lot-head { all: unset; box-sizing: border-box; width: 100%; display: grid; grid-template-columns: 22px minmax(150px, 1.2fr) minmax(80px, 1fr) repeat(3, minmax(88px, auto)); align-items: center; gap: 1rem; padding: .85rem 1.1rem; cursor: pointer; }
.lot-head:hover:not(:disabled) { background: var(--surface-2, var(--surface-3)); } .lot-head:disabled { cursor: default; }
.lot-head:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.lot-chev { display: grid; place-items: center; transition: transform .18s var(--ease); color: var(--ink-3); } .lot-chev.open { transform: rotate(180deg); } .lot-head:disabled .lot-chev { opacity: .25; }
.lot-id b { display: block; font-weight: 650; } .lot-id small { color: var(--ink-3); font-size: .8rem; } .lot-id .bad, .lot-num b.bad { color: var(--bad); }
.lot-bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; } .lot-bar i { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.lot-num { display: grid; text-align: right; line-height: 1.25; } .lot-num small { color: var(--ink-3); font-size: .72rem; } .lot-num b { font-variant-numeric: tabular-nums; font-weight: 650; } .lot-num.use b { color: var(--primary-ink); }
.lot-body { border-top: 1px solid var(--line); background: var(--surface); }
@media (max-width: 760px) { .lot-head { grid-template-columns: 22px 1fr auto auto; } .lot-bar { display: none; } .lot-num:nth-of-type(1) { display: none; } }

/* ---------- Accettazione merci ---------- */
.acc-todo { margin-bottom: 1.2rem; } .acc-todo header { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; } .acc-todo h2 { font-size: 1rem; }
.acc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .8rem; }
.acc-card { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--warn, #d99a1e); border-radius: var(--radius); padding: .85rem 1rem; display: grid; gap: .55rem; box-shadow: var(--shadow-1); }
.acc-card-top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; } .acc-card-top a { text-decoration: none; color: var(--ink); } .acc-card-top b { font-size: 1.02rem; }
.acc-card-who { display: flex; align-items: center; gap: .5rem; color: var(--ink-2); font-size: .9rem; } .acc-card-who .icon { width: 17px; height: 17px; color: var(--ink-3); flex: none; }
.acc-card-foot { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding-top: .55rem; border-top: 1px dashed var(--line); }

.acc-sum { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); margin-bottom: 1rem; overflow: hidden; }
.acc-sum-main { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.acc-sum-main > div { padding: .9rem 1.1rem; border-right: 1px solid var(--line); display: grid; gap: .15rem; align-content: start; } .acc-sum-main > div:last-child { border-right: 0; }
.acc-sum .sl { font-size: .74rem; color: var(--ink-3); } .acc-sum-main b { font-weight: 650; overflow-wrap: anywhere; } .acc-sum-main small { color: var(--ink-3); }
.acc-progress { padding: .8rem 1.1rem 1rem; border-top: 1px solid var(--line); background: var(--surface-2, var(--surface-3)); }
.acc-progress-top { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }
.acc-progress-bar { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; } .acc-progress-bar i { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .3s var(--ease); }
.acc-bulk-t { margin-right: .3rem; }
.acc-rows { display: grid; gap: .8rem; }
.acc-row { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.acc-row.is-bad { border-left-color: var(--bad); background: color-mix(in srgb, var(--bad) 5%, var(--surface)); } .acc-row.is-warn { border-left-color: var(--warn, #d99a1e); }
.acc-row-head { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) auto; gap: 1rem; align-items: center; padding: .85rem 1.1rem; border-bottom: 1px solid var(--line); }
.acc-row-id b { display: block; font-weight: 650; } .acc-row-id span { color: var(--ink-3); font-size: .86rem; }
.acc-row-lot { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.chip-lot { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border-radius: 99px; background: var(--surface-3); font-weight: 600; font-size: .85rem; } .chip-lot .icon { width: 14px; height: 14px; color: var(--ink-3); }
.acc-row-kg { text-align: right; } .acc-row-kg b { font-size: 1.15rem; font-variant-numeric: tabular-nums; } .acc-row-kg small { color: var(--ink-3); margin-left: .25rem; }
.acc-row-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .9rem 1.1rem; padding: .95rem 1.1rem 1.1rem; align-items: start; }
.acc-row-body .field:first-child { grid-column: span 2; } .acc-row-body .span-all { grid-column: 1 / -1; }
.acc-flags { display: grid; gap: .45rem; align-content: start; }
.seg.esito { display: flex; width: 100%; } .seg.esito button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .5rem .6rem; } .seg.esito .icon { width: 16px; height: 16px; }
.seg.esito .s-ok[aria-pressed="true"] { background: var(--ok, #1c8f5a); color: #fff; } .seg.esito .s-bad[aria-pressed="true"] { background: var(--bad); color: #fff; } .seg.esito .s-warn[aria-pressed="true"] { background: var(--warn, #d99a1e); color: #fff; }
.acc-after { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: .55rem; font-size: .86rem; color: var(--ink-2); }
@media (max-width: 760px) { .acc-row-head { grid-template-columns: 1fr auto; } .acc-row-lot { grid-column: 1 / -1; order: 3; } .acc-row-body .field:first-child { grid-column: 1 / -1; } .acc-sum-main > div { border-right: 0; border-bottom: 1px solid var(--line); } }

/* Filtri per colonna: pannello a comparsa come in Excel */
.fp { display: inline-block; position: relative; vertical-align: middle; margin-left: 2px; }
.fp-btn { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--ink-3); cursor: pointer; opacity: .55; }
.fp-btn svg { width: 14px; height: 14px; }
.table th:hover .fp-btn, .fp-btn:focus-visible { opacity: 1; }
.fp-btn:hover { background: var(--surface-3); color: var(--ink); opacity: 1; }
.fp-btn.on { opacity: 1; background: var(--primary); color: var(--on-primary); }
.fp-backdrop { position: fixed; inset: 0; z-index: 1999; background: transparent; cursor: default; }
.fp-pop { position: fixed; z-index: 2000; width: 290px; max-width: calc(100vw - 16px); background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow-3); padding: .4rem; display: flex; flex-direction: column; text-transform: none; letter-spacing: 0; font-weight: 400; font-size: .88rem; text-align: left; cursor: default; }
.fp-item { display: flex; align-items: center; gap: .55rem; width: 100%; padding: .45rem .55rem; border: 0; border-radius: var(--radius-s); background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.fp-item:hover { background: var(--surface-3); }
.fp-item svg { width: 15px; height: 15px; color: var(--ink-3); flex: none; }
.fp-sep { height: 1px; background: var(--line); margin: .35rem .2rem; }
.fp-lbl { font-size: .74rem; font-weight: 650; color: var(--ink-3); margin-bottom: .3rem; }
.fp-range { padding: .1rem .35rem .2rem; display: grid; gap: .3rem; }
.fp-range label { display: flex; align-items: center; gap: .5rem; margin: 0; font-weight: 500; font-size: .84rem; }
.fp-range label span { width: 2rem; color: var(--ink-3); flex: none; }
.fp-range input { min-height: 32px; padding: .25rem .5rem; font-size: .86rem; width: 100%; }
.fp-search { position: relative; padding: 0 .2rem .35rem; }
.fp-search svg { position: absolute; left: .75rem; top: 50%; transform: translateY(-65%); width: 15px; height: 15px; color: var(--ink-3); pointer-events: none; }
.fp-search input { width: 100%; min-height: 34px; padding: .3rem .6rem .3rem 2rem; font-size: .86rem; }
.fp-list { overflow-y: auto; max-height: 230px; border: 1px solid var(--line); border-radius: var(--radius-s); margin: 0 .2rem; padding: .2rem; background: var(--surface); }
.fp-opt { display: flex; align-items: center; gap: .55rem; padding: .3rem .45rem; margin: 0; border-radius: 5px; cursor: pointer; font-weight: 400; font-size: .86rem; line-height: 1.25; }
.fp-opt:hover { background: var(--surface-2); }
.fp-opt input { width: 16px; height: 16px; min-height: 0; margin: 0; flex: none; accent-color: var(--primary); }
.fp-opt span { overflow-wrap: anywhere; }
.fp-all { font-weight: 600; border-bottom: 1px solid var(--line); border-radius: 5px 5px 0 0; margin-bottom: .15rem; }
.fp-msg { padding: .6rem .6rem; color: var(--ink-3); font-size: .84rem; }
.fp-foot { display: flex; align-items: center; gap: .4rem; padding: .55rem .2rem .15rem; }
.filter-chips { display: flex; flex-wrap: wrap; gap: .4rem; padding: .55rem 1.1rem; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.fchip { display: inline-flex; align-items: center; gap: .35rem; padding: .18rem .3rem .18rem .65rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary-ink); font-size: .8rem; max-width: 100%; }
.fchip b { font-weight: 650; }
.fchip button { width: 18px; height: 18px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; line-height: 1; padding: 0; font-size: 14px; }
.fchip button:hover { background: rgba(0,0,0,.1); }
.table tr.nessun-risultato td { text-align: center; color: var(--ink-3); padding: 1.6rem 1rem; }
.btn-primary-soft { background: var(--primary-soft); color: var(--primary-ink); border-color: var(--primary); }

/* Griglie dentro altri riquadri e titoli di sezione */
.card > .card { border: 0; box-shadow: none; background: transparent; border-radius: 0; margin: 0; }
.section-head { display: flex; align-items: center; gap: .6rem; margin: 0 0 .6rem; }
.section-head h2 { margin: 0; font-size: 1.05rem; }

/* Registro attività: dettaglio modifiche */
.reg-dett { margin-top: .9rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); max-height: 50vh; overflow: auto; }
.reg-riga { display: grid; grid-template-columns: minmax(8rem, 12rem) 1fr; gap: .8rem; padding: .45rem .8rem; border-bottom: 1px solid var(--line); font-size: .9rem; }
.reg-riga:last-child { border-bottom: 0; }
.reg-campo { color: var(--ink-3); font-weight: 600; }
.reg-valore { overflow-wrap: anywhere; white-space: pre-wrap; }

/* logo più grande nel login */
.auth-brand .brand-grande { gap: .9rem; }
.auth-brand .brand-grande .brand-mark { width: 58px; height: 58px; }
.auth-brand .brand-grande .brand-name { font-size: 1.7rem; }

/* importi incolonnati: cifre a larghezza fissa, allineate a destra con decimali fissi */
.dl-importi { grid-template-columns: 1fr auto; max-width: 340px; }
.dl-importi dd { text-align: right; font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; white-space: nowrap; }

.seg > button:has(.icon) { display: inline-flex; align-items: center; gap: .45rem; }
.seg > button .icon { width: 17px; height: 17px; }
