@font-face {
  font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("fonts/ibm-plex-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("fonts/ibm-plex-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/ibm-plex-mono-400-latin.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/ibm-plex-mono-500-latin.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --bg: #fafafa;
  --surface: #ffffff;
  --raised: #f4f4f5;
  --raised-2: #ececee;
  --ink: #18181b;
  --text: #171717;
  --text-2: #525252;
  --muted: #6e6e73;
  --line: rgb(23 23 23 / 0.08);
  --line-2: rgb(23 23 23 / 0.14);
  --ok: #15803d;
  --ok-bg: #effaf2;
  --warn: #a16207;
  --warn-bg: #fdf7e7;
  --err: #b91c1c;
  --err-bg: #fdf1f1;
  --info: #1d4ed8;
  --info-bg: #eff4fe;
  --focus: #2563eb;
  --r-s: 6px;
  --r: 8px;
  --r-l: 12px;
  --r-xl: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --shadow-float: 0 12px 32px rgb(0 0 0 / 0.10), 0 2px 6px rgb(0 0 0 / 0.05);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 14px/20px var(--sans);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgb(24 24 27 / 0.14); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 24px; line-height: 32px; font-weight: 500; letter-spacing: -0.01em; text-wrap: balance; }
h2 { font-size: 16px; line-height: 24px; font-weight: 500; }
.h3 { font-size: 14px; font-weight: 500; margin-block: 24px 8px; }
a { color: inherit; text-underline-offset: 3px; text-decoration-color: var(--line-2); }
a:hover { text-decoration-color: currentColor; }
.num, .mono-s, .mono-input { font-variant-numeric: tabular-nums; }
.num { font-feature-settings: "tnum"; }
.mono-s, .mono-input { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; }
.r { text-align: end; }
.sr-only:where(:not(:focus-within, :active)) {
  position: absolute !important; clip-path: inset(50%) !important; overflow: hidden !important;
  width: 1px !important; height: 1px !important; margin: -1px !important; padding: 0 !important;
  border: 0 !important; white-space: nowrap !important;
}
.skip { position: absolute; inset-inline-start: 16px; inset-block-start: -48px; z-index: 50; }
.skip:focus { inset-block-start: 8px; background: var(--surface); padding: 8px 12px; border-radius: var(--r); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.i { inline-size: 16px; block-size: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round; }

/* ---------- barra superiore ---------- */
.top { position: sticky; inset-block-start: 0; z-index: 10; background: rgb(250 250 250 / 0.92);
  backdrop-filter: saturate(1.4) blur(8px); border-block-end: 1px solid var(--line); }
.top-in { max-inline-size: 1600px; margin-inline: auto; block-size: 56px; padding-inline: 24px;
  display: flex; align-items: center; gap: 24px; }
.brand { font-size: 15px; font-weight: 600; text-decoration: none; letter-spacing: -0.005em; white-space: nowrap; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 12px; border-radius: var(--r); text-decoration: none; color: var(--text-2);
  transition: background-color 140ms var(--ease), color 140ms var(--ease); }
.nav a:hover { background: var(--raised); color: var(--text); }
.nav a[aria-current="page"] { background: var(--raised-2); color: var(--text); font-weight: 500; }
.credit { margin-inline-start: auto; display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  color: var(--text-2); padding: 6px 12px; border-radius: var(--r); white-space: nowrap; }
.credit:hover { background: var(--raised); color: var(--text); }
.credit .num { font-family: var(--mono); font-size: 13px; color: var(--text); }
.credit .sep { color: var(--muted); }

/* ---------- pagina ---------- */
.page { max-inline-size: 1600px; margin-inline: auto; padding: 24px 24px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-block-end: 20px; }
.page-head p { margin-block-start: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions form { display: contents; }
.crumbs { display: flex; align-items: center; gap: 4px; color: var(--muted); margin-block-end: 12px; font-size: 13px; }
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); }
.card-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-block-end: 1px solid var(--line); }
.card-bar-end { border-block-end: 0; border-block-start: 1px solid var(--line); justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---------- messaggi ---------- */
.flash { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: var(--r);
  margin-block-end: 16px; border: 1px solid transparent; }
.flash .i { margin-block-start: 2px; }
.flash-ok { background: var(--ok-bg); color: var(--ok); border-color: rgb(21 128 61 / 0.16); }
.flash-err { background: var(--err-bg); color: var(--err); border-color: rgb(185 28 28 / 0.16); }
.err-text { color: var(--err); display: block; }
.warn-line { display: flex; gap: 8px; align-items: center; color: var(--warn); font-size: 13px; }
.warn-line[hidden] { display: none; }

/* ---------- bottoni ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; block-size: 36px; padding-inline: 14px;
  font: 500 14px/1 var(--sans); color: var(--text); background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--r); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease), color 140ms var(--ease), transform 120ms var(--ease); }
.btn:hover { background: var(--raised); border-color: rgb(23 23 23 / 0.2); }
.btn:active { transform: scale(0.98); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--ink); color: #fafafa; border-color: var(--ink); }
.btn-primary:hover { background: #2a2a2e; border-color: #2a2a2e; }
.btn-quiet { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-quiet:hover { background: var(--raised); border-color: transparent; color: var(--text); }
.btn-icon { inline-size: 32px; block-size: 32px; padding: 0; }
.btn-s { block-size: 28px; padding-inline: 10px; font-size: 13px; }
.btn-danger:hover { color: var(--err); background: var(--err-bg); }
.btn-danger-solid { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger-solid:hover { background: #991b1b; border-color: #991b1b; }
.btn-block { inline-size: 100%; block-size: 40px; }
form.is-busy .btn[type="submit"], .btn.is-busy { opacity: 0.6; pointer-events: none; }

/* ---------- campi ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-inline-size: 0; }
.label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.hint { font-size: 12px; line-height: 16px; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--r); min-block-size: 36px; padding: 7px 10px; inline-size: 100%;
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease); }
textarea { resize: vertical; line-height: 20px; }
input::placeholder, textarea::placeholder { color: #8e8e93; }
input:hover, select:hover, textarea:hover { border-color: rgb(23 23 23 / 0.24); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--ink);
  box-shadow: 0 0 0 3px rgb(24 24 27 / 0.1); }
input[type="checkbox"] { inline-size: 16px; block-size: 16px; min-block-size: 0; padding: 0; margin: 0; accent-color: var(--ink); flex: none; }
select { appearance: none; padding-inline-end: 32px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 16px; }
.error-msg { display: none; align-items: center; gap: 6px; font-size: 12px; color: var(--err); }
:is(input, textarea):is(:user-invalid, .user-invalid-fallback) { border-color: var(--err); background: var(--err-bg); }
.field:has(:user-invalid) .error-msg { display: flex; }
.check { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.check input { margin-block-start: 2px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- filtri ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-block-end: 12px; }
.search { position: relative; flex: 1 1 280px; display: block; }
.search .i { position: absolute; inset-inline-start: 12px; inset-block-start: 10px; color: var(--muted); }
.search input { padding-inline-start: 36px; }
.field-inline { display: flex; flex-direction: column; gap: 4px; }
.field-inline .label { font-size: 12px; color: var(--muted); font-weight: 400; }
.field-inline select { min-inline-size: 150px; }
.w-price { inline-size: 104px; }
.flags { display: flex; gap: 16px; align-items: center; border: 0; padding: 0 4px; margin: 0; block-size: 36px; }
.filters-end { display: flex; gap: 4px; }
.facets { display: flex; align-items: baseline; gap: 12px; margin-block-end: 8px; }
.facets:last-of-type { margin-block-end: 16px; }
.facets-label { inline-size: 76px; flex: none; font-size: 12px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; block-size: 28px; padding-inline: 10px; border-radius: var(--r-s);
  text-decoration: none; color: var(--text-2); border: 1px solid var(--line); background: var(--surface); font-size: 13px;
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease), color 140ms var(--ease); }
.chip:hover { border-color: var(--line-2); color: var(--text); }
.chip[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: #fafafa; }
.chip-n { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.chip[aria-current="true"] .chip-n { color: rgb(250 250 250 / 0.66); }

/* ---------- tabelle ---------- */
.table-wrap { overflow: auto; max-block-size: calc(100dvh - 200px); container-type: inline-size;
  border-end-start-radius: var(--r-l); border-end-end-radius: var(--r-l); overscroll-behavior: contain; }
.table { inline-size: 100%; border-collapse: separate; border-spacing: 0; }
.table thead th { position: sticky; inset-block-start: 0; z-index: 1; background: var(--surface);
  font-size: 12px; font-weight: 500; color: var(--muted); text-align: start; white-space: nowrap;
  padding: 10px 12px; border-block-end: 1px solid var(--line-2); }
.table thead th.r { text-align: end; }
.table :is(td, tbody th) { padding: 12px; border-block-end: 1px solid var(--line); vertical-align: middle; text-align: start; font-weight: 400; }
.table :is(td, tbody th).r { text-align: end; }
.table-dense :is(td, tbody th) { padding-block: 8px; }
.table tbody tr:last-child :is(td, th) { border-block-end: 0; }
.table tbody tr { transition: background-color 140ms var(--ease); }
.table tbody tr:hover { background: #fbfbfb; }
.table tbody tr.is-new { background: var(--info-bg); }
.table td.num, .table .price { font-family: var(--mono); font-size: 13px; }
.price .cur { color: var(--muted); font-size: 11px; }
.truncate { max-inline-size: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-cell a { text-decoration: none; color: var(--text-2); }
.link-cell a:hover { color: var(--text); text-decoration: underline; }
.svc { min-inline-size: 280px; max-inline-size: 560px; }
.svc-name { display: block; line-height: 20px; }
.svc-meta { display: block; font-size: 12px; line-height: 16px; color: var(--muted); margin-block-start: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.row-actions { white-space: nowrap; text-align: end; }
.row-actions > * { display: inline-flex; vertical-align: middle; }
.empty { padding: 48px 16px !important; text-align: center !important; color: var(--text-2); }
.opts { white-space: nowrap; }
.tag { display: inline-flex; align-items: center; block-size: 20px; padding-inline: 6px; border-radius: 4px;
  font-size: 11px; color: var(--text-2); background: var(--raised); margin-inline-end: 4px; }
.tag-type { color: var(--info); background: var(--info-bg); }
.tag-warn { color: var(--warn); background: var(--warn-bg); }
.state { max-inline-size: 280px; }
.pager { display: flex; align-items: center; gap: 4px; }
.pager-count { color: var(--muted); font-size: 13px; margin-inline-end: 8px; }

/* pallino di stato del fornitore: la firma della console */
.dot { inline-size: 8px; block-size: 8px; border-radius: 50%; flex: none; display: inline-block; }
.dot-ok { background: var(--ok); box-shadow: 0 0 0 3px rgb(21 128 61 / 0.14); }
.dot-err { background: var(--err); box-shadow: 0 0 0 3px rgb(185 28 28 / 0.14); }
.dot-off { background: transparent; border: 1.5px solid #a1a1a6; }

/* stati ordine */
.status { display: inline-flex; align-items: center; block-size: 22px; padding-inline: 8px; border-radius: var(--r-s);
  font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--raised); color: var(--text-2); }
.status-completato { background: var(--ok-bg); color: var(--ok); }
.status-in-attesa, .status-in-invio { background: var(--warn-bg); color: var(--warn); }
.status-in-corso { background: var(--info-bg); color: var(--info); }
.status-parziale { background: var(--warn-bg); color: var(--warn); }
.status-errore { background: var(--err-bg); color: var(--err); }
.progress { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.progress .bar { inline-size: 72px; block-size: 4px; border-radius: 2px; background: var(--raised-2); overflow: hidden; }
.progress .bar span { display: block; block-size: 100%; background: var(--ink); border-radius: 2px; }

/* ---------- registro dei saldi (il momento della console) ---------- */
.ledger { display: grid; grid-template-columns: repeat(auto-fill, minmax(208px, 1fr)); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; margin-block-end: 24px; }
.ledger-cell { box-shadow: 1px 1px 0 var(--line); padding: 16px 20px; display: flex; flex-direction: column; gap: 4px; min-inline-size: 0; }
.ledger-name { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.ledger-amount { font-family: var(--mono); font-size: 28px; line-height: 36px; font-weight: 500; letter-spacing: -0.02em; color: var(--ink); }
.ledger-amount small { font-size: 12px; letter-spacing: 0; color: var(--muted); margin-inline-start: 6px; font-weight: 400; }
.ledger-meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ledger-cell.is-zero .ledger-amount { color: #a1a1a6; }
.ledger-cell.is-err .ledger-meta { color: var(--err); }
.ledger-amount.is-empty { color: #a1a1a6; }

/* ---------- dettaglio ---------- */
.detail { padding: 20px 24px 24px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px 24px; margin: 0; }
.facts dt { font-size: 12px; color: var(--muted); margin-block-end: 4px; }
.facts dd { margin: 0; }
.facts dd a { display: inline-flex; align-items: center; gap: 6px; }
.comments { font-family: var(--mono); font-size: 12px; background: var(--raised); padding: 12px; border-radius: var(--r);
  white-space: pre-wrap; margin: 0; max-block-size: 320px; overflow: auto; }

/* ---------- dialog ---------- */
.dialog { inline-size: min(560px, calc(100vw - 32px)); max-block-size: calc(100dvh - 48px); padding: 0; border: 1px solid var(--line);
  border-radius: var(--r-xl); background: var(--surface); color: var(--text); box-shadow: var(--shadow-float); }
.dialog-s { inline-size: min(440px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgb(23 23 23 / 0.36); overflow: hidden; overscroll-behavior: contain; }
dialog:modal { overscroll-behavior: contain; }
.dialog[open] { animation: rise 220ms var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.dialog-body { padding: 24px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-block-end: 4px; }
.dialog-head h2 { overflow-wrap: anywhere; }
.dialog-head .hint { margin-block-start: 4px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding-block-start: 8px; }
.sum { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px 16px; background: var(--raised); border-radius: var(--r); }
.sum > div { display: flex; flex-direction: column; gap: 2px; }
.sum .label { font-weight: 400; font-size: 12px; color: var(--muted); }
.sum strong { font-family: var(--mono); font-size: 18px; line-height: 24px; font-weight: 500; }
.sum span.num { font-family: var(--mono); font-size: 14px; line-height: 24px; }
.drip summary { cursor: pointer; font-size: 13px; color: var(--text-2); }
.drip[open] summary { margin-block-end: 12px; }
.drip .hint { margin-block-start: 8px; }
[data-when][hidden], [data-when-drip][hidden] { display: none; }

/* ---------- login ---------- */
.login-body { min-block-size: 100dvh; display: grid; place-items: center; padding: 16px; }
.login { inline-size: min(360px, 100%); display: flex; flex-direction: column; gap: 8px; }
.login .brand { font-size: 20px; }
.login > p { margin-block-end: 16px; }
.login .stack { gap: 16px; margin-block-start: 8px; }

/* ---------- schermi stretti: tabelle a schede ---------- */
@container (width < 720px) {
  .table, .table thead, .table tbody, .table tr, .table td, .table tbody th { display: block; }
  .table thead { display: none; }
  .table tbody tr { padding: 12px 16px; border-block-end: 1px solid var(--line); }
  .table tbody tr:last-child { border-block-end: 0; }
  .table :is(td, tbody th) { border: 0; padding: 4px 0; text-align: start !important; max-inline-size: none; }
  .table :is(td, tbody th)[data-label]:not(.svc)::before { content: attr(data-label); display: inline-block;
    min-inline-size: 104px; font-size: 12px; color: var(--muted); font-family: var(--sans); }
  .table .svc { padding-block-end: 8px; min-inline-size: 0; }
  .table .svc-meta { white-space: normal; }
  .row-actions { text-align: start; padding-block-start: 8px !important; }
  .truncate { max-inline-size: 100%; }
  .empty::before { content: none !important; }
}

@media (max-width: 760px) {
  .top-in { padding-inline: 16px; gap: 12px; flex-wrap: wrap; block-size: auto; padding-block: 8px; }
  .credit { order: 3; margin-inline-start: 0; padding-inline: 0; }
  .top form { order: 4; margin-inline-start: auto; }
  .page { padding: 16px 16px 48px; }
  .table-wrap { max-block-size: none; }
  .facets { flex-direction: column; gap: 6px; }
  .filters > * { flex: 1 1 140px; }
  .search { flex-basis: 100%; }
  .field-inline select, .w-price { inline-size: 100%; min-inline-size: 0; }
  .row { grid-template-columns: 1fr; }
  .ledger { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .ledger-amount { font-size: 22px; line-height: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
