/* Borsino Agricolo — stile comune. Regole: docs/manifesto-grafico.md.
   I colori esistono SOLO qui nel blocco :root; altrove si usano le variabili (bin/audit.php lo controlla). */

/* Inter dal pacchetto Debian fonts-inter (bin/deploy.sh copia gli OTF): se mancano, si ricade su system-ui. */
@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("/assets/fonts/Inter-Regular.otf") format("opentype"); }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url("/assets/fonts/Inter-Medium.otf") format("opentype"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("/assets/fonts/Inter-SemiBold.otf") format("opentype"); }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url("/assets/fonts/Inter-Bold.otf") format("opentype"); }

:root {
  /* marca: blu navale (istituzione) e verde foresta (agricoltura) */
  --navy: #14213D;
  --navy-ink: #0B1426;
  --navy-hover: #1E3157;
  --navy-deep: #101B33;
  --navy-line: #2A3B5F;
  --forest: #1F4D3A;
  --forest-deep: #183F2F;
  --forest-ink: #0F2A1F;
  --forest-hover: #1B4231;
  --forest-mid: #2E6A50;
  --forest-line: #8FB8A3;
  --forest-soft: #E6EFEA;
  --forest-tint: #F2F7F4;
  --on-dark: #F1F6F3;
  --on-dark-soft: #B9CEC3;
  --wheat: #E2C275;
  /* grigi freddi */
  --slate: #334155;
  --slate-soft: #64748B;
  --line: #E1E6ED;
  --line-strong: #C3CCD8;
  --panel: #F4F6F9;
  --zebra: #F9FAFC;
  --paper: #FFFFFF;
  /* avvisi, errori */
  --amber: #8A5A00;
  --amber-strong: #B45309;
  --amber-hover: #9A4708;
  --amber-line: #EBC77E;
  --amber-soft: #FDF6E7;
  --oxide: #9B2C2C;
  --oxide-line: #E7B4B4;
  --oxide-soft: #FBEEEE;
  --focus: #2563EB;
  /* ombre morbide e leggere */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-md: 0 4px 10px -2px rgba(16, 24, 40, .08), 0 2px 4px -2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 30px 60px -20px rgba(8, 20, 14, .45), 0 12px 24px -12px rgba(8, 20, 14, .25);
  --shadow-pop: 0 12px 32px -8px rgba(16, 24, 40, .22);
  --scrim: rgba(255, 255, 255, .08);
  --scrim-strong: rgba(255, 255, 255, .16);
  --radius: 6px;
  --radius-lg: 8px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  /* icone per gli avvisi (maschere: il colore lo dà background-color) */
  --mask-warn: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z'/%3E%3Cpath d='M12 9v4M12 17h.01'/%3E%3C/svg%3E");
  --mask-ok: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m8 12 3 3 5-6'/%3E%3C/svg%3E");
  --mask-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5M12 8h.01'/%3E%3C/svg%3E");
  --mask-error: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v6M12 16.5h.01'/%3E%3C/svg%3E");
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--navy-ink); background: var(--panel);
  -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
a { color: var(--navy); text-underline-offset: 2px; }
a:hover { color: var(--forest); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; font-weight: 600; letter-spacing: -0.01em; color: var(--navy-ink); }
h1 { font-size: 24px; letter-spacing: -0.02em; } h2 { font-size: 18px; } h3 { font-size: 15px; }
p { margin: 0 0 1em; }
ul, ol { padding-left: 20px; }
code { font-family: var(--mono); font-size: .92em; background: var(--panel); border: 1px solid var(--line); padding: 0 4px; border-radius: 4px; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--slate-soft); }
.small { font-size: 12px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

/* ── icone (icon() in helpers.php) */
.ico { width: 18px; height: 18px; flex: none; }
.ico-logo { width: 32px; height: 32px; flex: none; }
.ico-logo .lg-stem { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; }
.ico-logo .lg-grain { fill: var(--wheat); }
.ico-logo .lg-leaf { fill: currentColor; }

/* ── marchio: spiga + «BORSINO / AGRICOLO» su due righe (file vettoriali in public/assets/brand/) */
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--forest); line-height: 1; }
.logo:hover { color: var(--forest); }
.logo-text { display: flex; flex-direction: column; gap: 3px; }
.logo-name { font-weight: 700; font-size: 13px; letter-spacing: .09em; text-transform: uppercase; line-height: 1.08; color: var(--navy-ink); }
.logo-by { font-size: 10.5px; font-weight: 500; letter-spacing: .02em; color: var(--slate-soft); }
.logo-light, .logo-light:hover { color: var(--on-dark); }
.logo-light .logo-name { color: var(--on-dark); }
.logo-light .logo-by { color: var(--on-dark-soft); }
/* segno storico del marchio (brand_mark), ancora usato in qualche vista */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--navy); font-weight: 600; font-size: 16px; }
.brand-mark .bm-bg { fill: var(--navy); }
.brand-mark .bm-bar { fill: var(--paper); }
.brand-mark .bm-up { fill: var(--forest-soft); }

/* ── bottoni */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 14px;
  border: 1px solid var(--navy); border-radius: var(--radius); background: var(--navy); color: var(--paper);
  font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease; }
.btn:hover { background: var(--navy-hover); border-color: var(--navy-hover); color: var(--paper); }
.btn .ico { width: 16px; height: 16px; }
.btn-secondary { background: var(--paper); color: var(--navy-ink); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--panel); color: var(--navy-ink); border-color: var(--slate-soft); }
.btn-forest { background: var(--forest); border-color: var(--forest); }
.btn-forest:hover { background: var(--forest-mid); border-color: var(--forest-mid); }
.btn-amber { background: var(--amber-strong); border-color: var(--amber-strong); color: var(--paper); }
.btn-amber:hover { background: var(--amber-hover); border-color: var(--amber-hover); color: var(--paper); }
.btn-danger { background: var(--paper); color: var(--oxide); border-color: var(--oxide-line); }
.btn-danger:hover { background: var(--oxide-soft); color: var(--oxide); border-color: var(--oxide); }
.btn-link { background: none; border: 0; color: var(--navy); text-decoration: underline; padding: 0; min-height: 0; box-shadow: none; font: inherit; cursor: pointer; }
.btn-light { background: var(--paper); color: var(--forest-ink); border-color: var(--paper); }
.btn-light:hover { background: var(--forest-soft); border-color: var(--forest-soft); color: var(--forest-ink); }
.btn-ghost-light { background: transparent; color: var(--on-dark); border-color: var(--forest-line); box-shadow: none; }
.btn-ghost-light:hover { background: var(--scrim); color: var(--paper); border-color: var(--on-dark); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { min-height: 48px; padding: 0 22px; font-size: 16px; font-weight: 600; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ── moduli */
.form { display: grid; gap: 16px; max-width: 640px; }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.field label, .label { display: block; font-size: 12.5px; font-weight: 500; color: var(--slate); margin-bottom: 5px; }
.field .help { font-size: 12px; color: var(--slate-soft); margin-top: 4px; }
.field .error { font-size: 12px; color: var(--oxide); margin-top: 4px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=date],
input[type=datetime-local], input[type=search], input[type=file], select, textarea {
  font: inherit; color: var(--navy-ink); background: var(--paper); border: 1px solid var(--line-strong);
  border-radius: var(--radius); padding: 7px 10px; min-height: 36px; width: 100%; box-shadow: var(--shadow-sm);
  transition: border-color .12s ease, box-shadow .12s ease; }
input:hover, select:hover, textarea:hover { border-color: var(--slate-soft); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--forest-mid); box-shadow: 0 0 0 3px var(--forest-soft); }
textarea { min-height: 96px; resize: vertical; }
.w-xs { max-width: 96px; } .w-sm { max-width: 160px; } .w-md { max-width: 280px; } .w-lg { max-width: 420px; }
.check { display: flex; gap: 8px; align-items: flex-start; }
.check input { margin-top: 3px; accent-color: var(--forest); }
.hp { position: absolute; left: -10000px; }

/* ── avvisi: barra a sinistra, icona, testo che dice cosa fare */
.notice { position: relative; border: 1px solid var(--line); border-left: 3px solid var(--slate-soft); background: var(--paper);
  padding: 11px 14px 11px 42px; border-radius: var(--radius); margin: 0; color: var(--navy-ink); }
.notice::before { content: ""; position: absolute; left: 14px; top: 12px; width: 18px; height: 18px; background-color: var(--slate-soft);
  -webkit-mask: var(--mask-info) center / contain no-repeat; mask: var(--mask-info) center / contain no-repeat; }
.notice-ok { border-color: var(--forest-soft); border-left-color: var(--forest); background: var(--forest-tint); }
.notice-ok::before { background-color: var(--forest); -webkit-mask-image: var(--mask-ok); mask-image: var(--mask-ok); }
.notice-warn { border-color: var(--amber-line); border-left-color: var(--amber-strong); background: var(--amber-soft); }
.notice-warn::before { background-color: var(--amber-strong); -webkit-mask-image: var(--mask-warn); mask-image: var(--mask-warn); }
.notice-error { border-color: var(--oxide-line); border-left-color: var(--oxide); background: var(--oxide-soft); }
.notice-error::before { background-color: var(--oxide); -webkit-mask-image: var(--mask-error); mask-image: var(--mask-error); }
.notice ul { margin: 6px 0 0; }
.proof-stamp { border: 2px solid var(--oxide); color: var(--oxide); font-weight: 700; letter-spacing: .04em; padding: 6px 12px; display: inline-block; border-radius: var(--radius); background: var(--oxide-soft); }

/* ── badge di stato: pastiglia con pallino (il testo dice lo stato, il colore aiuta) */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; line-height: 18px; padding: 1px 9px 1px 8px;
  border-radius: 999px; border: 1px solid var(--line-strong); color: var(--slate); background: var(--paper); white-space: nowrap; vertical-align: middle; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge-published, .badge-open, .badge-signed, .badge-verified, .badge-awarded, .badge-delivered, .badge-converted, .badge-actioned {
  border-color: var(--forest-soft); color: var(--forest); background: var(--forest-soft); }
.badge-committed, .badge-awaiting_signatures, .badge-loading, .badge-sealed, .badge-requested, .badge-new, .badge-contacted, .badge-received {
  border-color: var(--amber-line); color: var(--amber); background: var(--amber-soft); }
.badge-disputed, .badge-suspended, .badge-cancelled { border-color: var(--oxide-line); color: var(--oxide); background: var(--oxide-soft); }
.badge-expired, .badge-withdrawn, .badge-closed, .badge-rejected, .badge-draft { color: var(--slate-soft); background: var(--panel); border-color: var(--line); }

/* ── schede */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; }
.card-head > a { margin-left: auto; font-size: 13px; font-weight: 500; }
.card > .card-head:first-child { margin: -20px -20px 16px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.card.stack > .card-head:first-child + * { margin-top: 0; }
.card h3 { font-size: 14px; }
.card-head .ico { color: var(--slate-soft); }
.kv { display: grid; grid-template-columns: minmax(140px, max-content) 1fr; gap: 0; margin: 0; }
.kv dt, .kv dd { padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv dt { color: var(--slate-soft); font-size: 12.5px; padding-right: 24px; }
.kv dd { margin: 0; }
.kv dd.num { text-align: left; }
.kv dt:last-of-type, .kv dd:last-of-type { border-bottom: 0; }
.secret { font-family: var(--mono); word-break: break-all; background: var(--panel); border: 1px solid var(--line); padding: 10px 12px; border-radius: var(--radius); }

/* elenchi di azioni dentro una scheda (es. «Prossime azioni»): righe con freccia */
.card > ul { list-style: none; margin: 0; padding: 0; }
.card > ul > li { border-bottom: 1px solid var(--line); }
.card > ul > li:last-child { border-bottom: 0; }
.card > ul > li > a { display: flex; align-items: center; gap: 12px; padding: 10px 2px; font-weight: 500; text-decoration: none; color: var(--navy-ink); }
.card > ul > li > a::after { content: "→"; margin-left: auto; color: var(--line-strong); }
.card > ul > li > a:hover { color: var(--forest); }
.card > ul > li > a:hover::after { color: var(--forest); }

/* ── tabelle dense (compratore e console): intestazione attaccata in alto, righe zebrate leggere */
.table-wrap { overflow: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); max-height: 75vh; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; }
table.data th { position: sticky; top: 0; z-index: 1; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--slate-soft);
  text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-strong); background: var(--panel); white-space: nowrap; }
table.data th.num { text-align: right; }
table.data th[aria-sort] { cursor: pointer; user-select: none; }
table.data th[aria-sort]:hover { color: var(--navy-ink); }
table.data th[aria-sort=ascending]::after { content: " ↑"; color: var(--forest); }
table.data th[aria-sort=descending]::after { content: " ↓"; color: var(--forest); }
table.data td { padding: 7px 12px; border-bottom: 1px solid var(--line); height: 34px; vertical-align: middle; }
table.data tbody tr:nth-child(even) td { background: var(--zebra); }
table.data tbody tr:hover td { background: var(--forest-tint); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td a { font-weight: 500; text-decoration: none; }
table.data td a:hover { text-decoration: underline; }
table.data td code { background: none; border: 0; padding: 0; color: var(--slate); font-size: 12px; }
table.data tfoot td { font-weight: 600; border-top: 1px solid var(--line-strong); background: var(--panel); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; padding: 12px 14px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.filters .field { min-width: 140px; }
.empty { color: var(--slate-soft); padding: 32px 24px; text-align: center; }
.card.empty { border-style: dashed; box-shadow: none; }

/* ── riquadri KPI: numero grande */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.kpi { position: relative; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px 18px; box-shadow: var(--shadow-sm); }
a.kpi { display: block; text-decoration: none; color: inherit; transition: box-shadow .12s ease, border-color .12s ease; }
a.kpi::after { content: "→"; position: absolute; right: 16px; top: 14px; color: var(--line-strong); transition: color .12s ease, transform .12s ease; }
a.kpi:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
a.kpi:hover::after { color: var(--forest); transform: translateX(2px); }
.kpi .kpi-label { font-size: 12px; font-weight: 500; color: var(--slate-soft); padding-right: 20px; }
.kpi .kpi-value { font-size: 32px; line-height: 1.15; margin-top: 6px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--navy-ink); }

/* ── intestazione di pagina: titolo a sinistra, azioni a destra */
.page-head { display: flex; align-items: flex-end; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--slate-soft); margin: 6px 0 0; max-width: 80ch; }
.page-head > div:first-child { min-width: 0; flex: 1 1 320px; }
.page-head form { margin: 0; }

/* ── AREA RISERVATA: barra superiore blu navale + schede di navigazione */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { background: var(--navy); color: var(--paper); box-shadow: var(--shadow-md); position: relative; z-index: 20; }
.topbar-in { max-width: 1320px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 12px; }
.topbar .logo .ico-logo { color: var(--forest-line); }
.topbar-co { padding-left: 16px; margin-left: 4px; border-left: 1px solid var(--navy-line); color: var(--line-strong); font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.topbar-ico { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius); color: var(--line); }
.topbar-ico:hover { background: var(--navy-hover); color: var(--paper); }
.usermenu { position: relative; }
.usermenu > summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px 4px 4px; border-radius: var(--radius);
  color: var(--paper); font-size: 13px; font-weight: 500; }
.usermenu > summary::-webkit-details-marker { display: none; }
.usermenu > summary:hover, .usermenu[open] > summary, .usermenu.is-on > summary { background: var(--navy-hover); }
.usermenu > summary > .ico { width: 14px; height: 14px; color: var(--line-strong); }
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--forest); color: var(--on-dark); flex: none; }
.avatar .ico { width: 16px; height: 16px; }
.usermenu-pop { position: absolute; right: 0; top: calc(100% + 8px); width: 260px; background: var(--paper); color: var(--navy-ink);
  border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); padding: 6px; z-index: 30; }
.usermenu-who { padding: 10px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.usermenu-who strong { display: block; font-size: 14px; }
.usermenu-who span { display: block; font-size: 12px; color: var(--slate-soft); }
.usermenu-pop a, .usermenu-pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--radius);
  color: var(--navy-ink); text-decoration: none; font: inherit; background: none; border: 0; cursor: pointer; text-align: left; min-height: 0; }
.usermenu-pop a:hover, .usermenu-pop button:hover { background: var(--panel); color: var(--navy-ink); }
.usermenu-pop a[aria-current=page] { background: var(--forest-tint); color: var(--forest); }
.usermenu-pop .ico { color: var(--slate-soft); }
.usermenu-pop form { margin: 6px 0 0; padding-top: 6px; border-top: 1px solid var(--line); }
.tabs { background: var(--navy-deep); border-top: 1px solid var(--navy-line); }
.tabs-in { max-width: 1320px; margin: 0 auto; padding: 0 16px; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs-in::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 11px 12px 10px; color: var(--line-strong); text-decoration: none;
  font-size: 13.5px; font-weight: 500; white-space: nowrap; border-bottom: 2px solid transparent; }
.tab .ico { width: 16px; height: 16px; opacity: .85; }
.tab:hover { color: var(--paper); background: var(--scrim); }
.tab[aria-current=page] { color: var(--paper); border-bottom-color: var(--wheat); }
.tab[aria-current=page] .ico { opacity: 1; color: var(--wheat); }
.tab-sep { width: 1px; background: var(--navy-line); margin: 10px 6px; flex: none; }
.app .main { width: 100%; max-width: 1320px; margin: 0 auto; padding: 28px 24px 56px; flex: 1; }
.flash { margin-bottom: 18px; }

/* ── CONSOLE: barra laterale verde molto scuro */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--forest-ink); color: var(--on-dark); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .logo { margin: 0 8px 6px; }
.side .logo .ico-logo { color: var(--forest-line); }
.side-role { margin: 4px 8px 6px; font-size: 10.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--wheat); }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side .nav-label { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--forest-line); margin: 18px 10px 6px; }
.side a.nav { display: flex; align-items: center; gap: 10px; color: var(--on-dark-soft); text-decoration: none; padding: 7px 10px;
  border-radius: var(--radius); font-size: 13.5px; font-weight: 500; }
.side a.nav .ico { width: 17px; height: 17px; opacity: .8; }
.side a.nav:hover { background: var(--forest-hover); color: var(--paper); }
.side a.nav[aria-current=page] { background: var(--forest); color: var(--paper); box-shadow: inset 3px 0 0 var(--wheat); }
.side a.nav[aria-current=page] .ico { opacity: 1; color: var(--wheat); }
.side .who { margin-top: auto; font-size: 12px; color: var(--on-dark-soft); padding: 14px 10px 4px; border-top: 1px solid var(--forest-hover);
  display: flex; align-items: center; gap: 10px; }
.side .who .avatar { background: var(--forest-mid); }
.side .who strong { display: block; color: var(--paper); font-weight: 500; font-size: 13px; }
.side .who form { margin: 2px 0 0; }
.side .who .btn-link { color: var(--on-dark-soft); font-size: 12px; }
.side .who .btn-link:hover { color: var(--paper); }
.side-toggle, .side-burger { display: none; }
.shell > .main { padding: 28px 32px 56px; min-width: 0; }

/* ── densità: compratore e console (terminale) */
.dense table.data td { padding: 5px 12px; height: 32px; font-size: 13px; }
.dense .card { padding: 18px; }
.dense .card > .card-head:first-child { margin: -18px -18px 14px; padding: 12px 18px; }

/* ── densità: venditore da telefono (piazzale, sole) */
.field-mode { font-size: 16px; }
.field-mode .main { max-width: 880px; }
.field-mode .btn { min-height: 52px; font-size: 17px; font-weight: 600; }
.field-mode .card .btn, .field-mode .list-item .btn { width: 100%; }
.field-mode input, .field-mode select, .field-mode textarea { min-height: 48px; font-size: 17px; }
.field-mode .field label { font-size: 14px; color: var(--navy-ink); font-weight: 600; }
.field-mode .kv dt { font-size: 13px; }
.field-mode .list-item { display: block; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px;
  text-decoration: none; color: var(--navy-ink); box-shadow: var(--shadow-sm); }
.field-mode .list-item + .list-item { margin-top: 12px; }
.field-mode .list-item .li-title { font-weight: 600; font-size: 17px; }
.field-mode .list-item .li-meta { color: var(--slate); font-size: 15px; margin-top: 4px; }
.field-mode .list-item form { margin-top: 12px; }
.field-mode .list-item br { display: none; }
.field-mode .usermenu-pop button, .field-mode .usermenu-pop a { font-size: 15px; }

/* ── tracciatore del contratto (8 passi): verdi i fatti, ambra il corrente, grigi i futuri */
.tracker { list-style: none; margin: 0; padding: 4px 0 2px; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); counter-reset: passo; }
.tracker li { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 0 4px;
  font-size: 12px; font-weight: 500; line-height: 1.3; color: var(--slate-soft); counter-increment: passo; }
.tracker li::before { content: counter(passo); position: relative; z-index: 1; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--paper); border: 2px solid var(--line-strong); color: var(--slate-soft); font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; flex: none; }
.tracker li + li::after { content: ""; position: absolute; top: 15px; right: 50%; width: 100%; height: 2px; background: var(--line-strong); }
.tracker li.is-done { color: var(--forest); }
.tracker li.is-done::before { content: "✓"; background: var(--forest); border-color: var(--forest); color: var(--paper); }
.tracker li.is-done::after, .tracker li.is-now::after, .tracker li.is-stop::after { background: var(--forest); }
.tracker li.is-now { color: var(--navy-ink); font-weight: 600; }
.tracker li.is-now::before { background: var(--amber-strong); border-color: var(--amber-strong); color: var(--paper); box-shadow: 0 0 0 4px var(--amber-soft); }
.tracker li.is-stop { color: var(--oxide); font-weight: 600; }
.tracker li.is-stop::before { content: "!"; background: var(--oxide); border-color: var(--oxide); color: var(--paper); box-shadow: 0 0 0 4px var(--oxide-soft); }
.tracker li small { display: block; font-weight: 400; color: var(--slate-soft); font-size: 11px; }
.tracker-note { margin: 16px 0 0; font-size: 13px; color: var(--slate); }
.card-sign { border-color: var(--amber-line); border-left: 4px solid var(--amber-strong); }
.card-sign > .card-head:first-child { background: var(--amber-soft); border-bottom-color: var(--amber-line); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.card-sign .card-head .ico { color: var(--amber-strong); }
.card-sign .btn-forest { background: var(--navy); border-color: var(--navy); }
.card-sign .btn-forest:hover { background: var(--navy-hover); border-color: var(--navy-hover); }
.card-load .card-head .ico { color: var(--forest); }

/* ── console: riquadri operativi */
.ops { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.op { display: flex; flex-direction: column; gap: 10px; }
.op h2 { font-size: 15px; margin: 0; }
.op p { margin: 0; color: var(--slate); }
.op .row { margin-top: auto; padding-top: 4px; gap: 8px; }
.op-ico { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius); background: var(--forest-soft); color: var(--forest); }
.op-warn { border-color: var(--amber-line); }
.op-warn .op-ico { background: var(--amber-soft); color: var(--amber-strong); }
.section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--slate-soft); margin: 0 0 10px; }

/* ── pagine di accesso: pannello di marca a lato */
.auth { display: grid; grid-template-columns: minmax(360px, 5fr) 7fr; min-height: 100vh; }
.auth-brand { position: relative; overflow: hidden; background: var(--forest-deep); color: var(--on-dark); padding: 40px 48px; display: flex; flex-direction: column; gap: 24px; }
.auth-console .auth-brand { background: var(--forest-ink); }
.auth-brand h2 { color: var(--paper); font-size: 30px; line-height: 1.2; letter-spacing: -0.02em; margin: auto 0 0; max-width: 16ch; position: relative; }
.auth-brand > p { color: var(--on-dark-soft); margin: 0; max-width: 42ch; position: relative; }
.auth-points { list-style: none; margin: 0 0 auto; padding: 0; display: grid; gap: 12px; position: relative; }
.auth-points li { display: flex; gap: 10px; align-items: flex-start; color: var(--on-dark); font-size: 14px; }
.auth-points .ico { color: var(--wheat); margin-top: 1px; }
.auth-art { position: absolute; right: -30px; bottom: 40px; width: 460px; opacity: .3; pointer-events: none; }
.auth-art path, .auth-art circle { fill: none; stroke: var(--forest-line); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.auth-foot { font-size: 12px; color: var(--on-dark-soft); position: relative; }
.auth-main { display: grid; place-items: center; padding: 40px 24px; background: var(--panel); }
.auth-card { width: 100%; max-width: 420px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow-md); }
.auth-card h1 { font-size: 22px; margin-bottom: 6px; }
.auth-card .form { max-width: none; margin-top: 18px; }
.auth-card .form > .btn, .auth-card .form > div > .btn { width: 100%; min-height: 42px; }
.auth-card > p.small:last-child { margin: 18px 0 0; padding-top: 16px; border-top: 1px solid var(--line); }
.auth-card > .notice { margin: 12px 0; }
.auth-card > br { display: none; }
.codes { font-family: var(--mono); font-size: 15px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; background: var(--panel); padding: 12px 14px; border-radius: var(--radius); }
.qr { width: 200px; height: 200px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }

@media (max-width: 430px) {
  .side-role { display: none; }
}
@media (max-width: 1080px) {
  .topbar-co { display: none; }
}
@media (max-width: 860px) {
  /* console: la barra laterale diventa una barra in alto con menu a scomparsa (senza script) */
  .shell { grid-template-columns: 1fr; }
  .side { position: relative; z-index: 20; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 16px; gap: 0; overflow: visible; }
  .side .logo { margin: 0; }
  .side-role { margin: 0 0 0 12px; }
  .side-burger { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; padding: 8px 12px; border-radius: var(--radius); border: 1px solid var(--forest-mid);
    color: var(--on-dark); cursor: pointer; font-size: 13px; font-weight: 500; }
  .side-nav { display: none; flex-basis: 100%; padding: 8px 0 4px; }
  .side-toggle:checked ~ .side-nav { display: flex; }
  .side-toggle:focus-visible + .side-burger { outline: 2px solid var(--focus); outline-offset: 2px; }
  .side-nav .nav-label { margin: 12px 10px 4px; }
  .side .who { margin-top: 10px; }
  .shell > .main { padding: 20px 16px 48px; }
  .topbar-in { padding: 8px 16px; gap: 6px; }
  .tabs-in { padding: 0 8px; }
  .app .main { padding: 20px 16px 48px; }
  .usermenu-name { display: none; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { border-bottom: 0; padding: 10px 0 0; }
  .kv dd { padding: 2px 0 10px; }
  .card { padding: 16px; }
  .card > .card-head:first-child, .dense .card > .card-head:first-child { margin: -16px -16px 14px; padding: 12px 16px; }
  .dense .card { padding: 16px; }
  h1 { font-size: 22px; }
  .page-head { margin-bottom: 16px; }
  .page-head .btn { flex: 1 1 auto; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 14px 14px; }
  .kpi .kpi-value { font-size: 26px; }
  .filters .field { min-width: 0; flex: 1 1 140px; }
  .filters .btn { flex: 1 1 auto; }
  /* tracciatore: in verticale */
  .tracker { grid-template-columns: 1fr; gap: 0; }
  .tracker li { flex-direction: row; text-align: left; align-items: center; gap: 12px; padding: 0 0 14px; font-size: 14px; }
  .tracker li + li::after { top: auto; bottom: calc(100% - 14px); right: auto; left: 14px; width: 2px; height: 100%; }
  .tracker li:last-child { padding-bottom: 0; }
  .field-mode .main { padding: 14px 12px 40px; }
  /* pagine di accesso: il pannello si riduce a una fascia */
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-brand { padding: 16px; gap: 0; }
  .auth-brand h2, .auth-brand > p, .auth-points, .auth-foot, .auth-art { display: none; }
  .auth-main { padding: 24px 16px 40px; place-items: start center; }
  .auth-card { padding: 22px 18px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  .side, .topbar, .tabs, .no-print { display: none !important; }
  .shell { display: block; }
  body { background: var(--paper); }
  .card, .table-wrap { box-shadow: none; }
  .table-wrap { max-height: none; overflow: visible; }
}

/* ── area dimostrativa: barra fissa in tutte le pagine di una sessione demo, schede della pagina /demo */
.demo-bar { position: sticky; top: 0; z-index: 50; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  padding: 8px 16px; background: var(--amber-soft); border-bottom: 2px solid var(--amber); color: var(--navy-ink); font-size: 14px; }
.demo-bar strong { font-weight: 600; }
.demo-bar form { margin: 0; }
.demo-bar .demo-bar-links { margin-left: auto; display: flex; gap: 16px; align-items: center; }
.field-mode .demo-bar .btn-link { width: auto; min-height: 0; font-size: 15px; }
.demo-cards { display: grid; gap: 16px; margin-bottom: 20px; }
.demo-card { display: flex; flex-direction: column; gap: 12px; }
.demo-card h3 { margin: 0; }
.demo-card p { margin: 0; color: var(--slate); flex: 1; }
@media (min-width: 860px) { .demo-cards { grid-template-columns: repeat(3, 1fr); } }
