:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1c2130;
  --muted: #5b6475;
  --border: #dde1e8;
  --accent: #a4161a; /* rosso cremisi del logo */
  --accent-hover: #861115;
  --accent-text: #ffffff;
  --icon-acc: #a4161a;
  --viewer-bg: #e4e7ec;
  --ok: #18794a;
  --ok-bg: #e5f4ec;
  --warn: #8f5a00;
  --warn-bg: #fdf1dc;
  --bad: #c0281b;
  --bad-bg: #fde8e6;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.06), 0 4px 16px rgb(16 24 40 / 0.08);
  --radius: 10px;
  --toolbar-h: 52px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1d22;
    --surface: #24272e;
    --surface-2: #2c3038;
    --text: #e7e9ee;
    --muted: #a2a9b7;
    --border: #383c46;
    /* rosso vero e non rosa (Alessandro, 30/10/2026: «quel rosino non mi piace»), chiaro quanto basta per il fondo scuro */
    --accent: #ec5a5f;
    --accent-hover: #f07378;
    --accent-text: #2a0b0c;
    --icon-acc: #e5484d;
    --viewer-bg: #2f333b;
    --ok: #5fd39a;
    --ok-bg: #173527;
    --warn: #f2bd5c;
    --warn-bg: #3a2d14;
    --bad: #ff8a7d;
    --bad-bg: #401c19;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 6px 20px rgb(0 0 0 / 0.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

/* Josefin Sans, la scritta del logo: nel sito, così va anche senza rete (licenza in fonts/LEGGIMI.txt). */
@font-face {
  font-family: "Josefin Sans";
  src: url("fonts/josefin-sans-latin.woff2") format("woff2");
  font-weight: 100 700;
  font-display: swap;
}
/* Josefin ha la linea di base alta: le scritte nei pulsanti si abbassano un poco. */
.btn-label { padding-top: 0.18em; }

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

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6; /* tratto come nel foglio «E» */
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon.muted { color: var(--muted); }

/* ------------------------------------------------------------ Pulsanti */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-family: "Josefin Sans", system-ui, sans-serif;
  font-weight: 500; /* medio, come la scritta del logo */
  letter-spacing: 0.02em;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:focus-visible, select:focus-visible, input:focus-visible, .sig-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); --icon-acc: currentColor; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.subtle { border-color: transparent; background: transparent; color: var(--accent); }
.btn.big { min-height: 46px; padding: 0 22px; font-size: 16px; border-radius: 10px; }
.btn.icon-only { width: 36px; padding: 0; border-color: transparent; background: transparent; }
.btn.icon-only:hover:not(:disabled) { background: var(--surface-2); }

/* ------------------------------------------------------------ Toolbar */

.toolbar {
  position: relative;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-height: var(--toolbar-h);
  padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tb-group { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tb-file { flex: 1 1 200px; }
.tb-view { gap: 14px; }
.tb-cluster { display: flex; align-items: center; gap: 2px; }
.tb-actions { margin-left: auto; }

.share-wrap { position: relative; }
.share-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  right: 0;
  display: grid;
  gap: 2px;
  min-width: 240px;
  max-width: min(320px, calc(100vw - 24px));
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.share-option {
  display: grid;
  gap: 1px;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.share-option:hover, .share-option:focus-visible { background: var(--surface-2); outline: none; }
.share-option span { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.doc-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.page-box { display: flex; align-items: center; gap: 6px; color: var(--muted); font-variant-numeric: tabular-nums; }
.page-box input {
  width: 3.4em;
  height: 32px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: center;
  -moz-appearance: textfield;
}
.page-box input::-webkit-outer-spin-button,
.page-box input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

#zoomSelect {
  height: 32px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.sig-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  max-width: 280px;
  min-height: 30px;
  padding: 0 10px 0 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.sig-chip .icon { width: 18px; height: 18px; }
.sig-chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sig-chip.valid { background: var(--ok-bg); color: var(--ok); }
.sig-chip.invalid { background: var(--bad-bg); color: var(--bad); }
.sig-chip.unknown { background: var(--warn-bg); color: var(--warn); }
.sig-chip.pending { background: var(--surface-2); color: var(--muted); }

/* ------------------------------------------------------------ Ricerca */

.findbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 15;
}
.findbar input {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 420px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.find-result { color: var(--muted); font-size: 13px; white-space: nowrap; }
.find-result.not-found { color: var(--bad); }

/* ------------------------------------------------------------ Area principale */

main {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--viewer-bg);
}

.viewer-container {
  position: absolute;
  inset: 0;
  overflow: auto;
  outline: none;
}
.pdfViewer { padding: 6px 0 16px; }
/* PDF.js dà alla pagina la larghezza del contenuto e ci aggiunge fuori un bordo di 9px:
   con il border-box generale la tela verrebbe schiacciata di 18px e il testo piccolo sfocato. */
.pdfViewer .page { box-sizing: content-box; }
/* Ombra della pagina: il bordo di PDF.js è trasparente, quindi la disegniamo all'interno. */
.pdfViewer .page::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.2), 0 4px 14px rgb(0 0 0 / 0.08);
}

/* Link nei PDF: niente riquadro giallo al passaggio del mouse. Molti programmi
   (Word, LibreOffice, LaTeX, convertitori HTML) salvano l'area del link sfasata
   rispetto al testo e l'evidenziazione risulterebbe spostata; come in Chrome e
   Acrobat restano la manina e il suggerimento con l'indirizzo. */
#viewer .annotationLayer .linkAnnotation > a:hover { opacity: 1; background: none; box-shadow: none; }
#viewer .annotationLayer .linkAnnotation.hasBorder:hover { background-color: transparent; }
#viewer .annotationLayer .linkAnnotation > a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.welcome {
  position: absolute;
  inset: 0;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--bg);
}
.drop-card {
  width: min(560px, 100%);
  padding: 40px 36px 28px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgb(20 24 40 / 0.06);
  text-align: center;
  transition: border-color 0.15s, background-color 0.15s;
}
/* Il tratteggio solo mentre si trascina un file (pareri di GPT, Gemini, DeepSeek e Grok, 29/10/2026). */
body.dragging .drop-card { border: 2px dashed var(--accent); background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.drop-icon {
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 8px;
  border-radius: 16px;
  background: var(--surface-2);
  color: var(--accent);
}
.drop-icon .icon { width: 32px; height: 32px; stroke-width: 1.6; }
.drop-logo { display: block; width: 96px; height: 96px; margin: 0 auto 10px; }
.drop-card h1 { margin: 22px 0 6px; font-family: "Josefin Sans", system-ui, sans-serif; font-size: 27px; font-weight: 700; line-height: 1.15; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 0; }
.brand strong { font-size: 15px; letter-spacing: 0.18em; color: var(--accent); }
.brand span { font-size: 13px; letter-spacing: 0.02em; color: var(--muted); }
body.outlook .brand { display: none; }
.drop-hint { margin: 0 0 18px; color: var(--muted); }
.formats { margin: 22px 0 0; color: var(--muted); font-size: 12.5px; }
.versione { margin: 10px 0 0; color: var(--muted); font-size: 11px; opacity: .75; }
.features {
  margin: 24px 0 8px;
  padding: 20px 0 0;
  border-top: 1px solid var(--border);
  list-style: none;
  text-align: left;
  display: grid;
  gap: 12px;
}
.features li { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: var(--muted); }
.features li strong { color: var(--text); }
.features .icon { margin-top: 1px; color: var(--text); }

/* ------------------------------------------------------------ Vista alternativa */

.alt-view {
  position: absolute;
  inset: 0;
  overflow: auto;
  padding: 20px 12px 32px;
}
.sheet {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 28px;
  background: #fff;
  color: #1c2130;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.18), 0 6px 18px rgb(0 0 0 / 0.08);
}
.sheet-note {
  max-width: 900px;
  margin: 0 auto 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
}
.text-view {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
.text-view.prose { font: 15px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.image-view { display: block; max-width: 100%; height: auto; margin: 0 auto; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.18); }
.message-card {
  max-width: 520px;
  margin: 8vh auto 0;
  padding: 28px;
  border-radius: 14px;
  background: var(--surface);
  text-align: center;
  box-shadow: var(--shadow);
}
.message-card h2 { margin: 6px 0 8px; font-size: 19px; }
.message-card p { margin: 0 0 18px; color: var(--muted); }
.message-card .icon.big { width: 40px; height: 40px; color: var(--accent); stroke-width: 1.6; }
.message-card .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

/* ------------------------------------------------------------ Pannello firme */

.sig-panel {
  position: absolute;
  z-index: 10;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: slide-in 0.18s ease-out;
}
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }
.sig-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 12px 18px;
  border-bottom: 1px solid var(--border);
}
.sig-panel-head h2 { margin: 0; font-size: 17px; }
.sig-panel-body { flex: 1; overflow: auto; padding: 16px 18px max(24px, env(safe-area-inset-bottom)); }

.summary {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.summary .icon { width: 26px; height: 26px; }
.summary h3 { margin: 0 0 2px; font-size: 15px; }
.summary p { margin: 0; font-size: 14px; }
.summary.valid { background: var(--ok-bg); color: var(--ok); }
.summary.invalid { background: var(--bad-bg); color: var(--bad); }
.summary.unknown { background: var(--warn-bg); color: var(--warn); }
.summary.pending { background: var(--surface-2); color: var(--muted); }
.summary p { color: var(--text); }

.layer-title {
  margin: 20px 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.signer {
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.signer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.signer-name { margin: 0; font-size: 16px; font-weight: 650; overflow-wrap: anywhere; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}
.badge .icon { width: 14px; height: 14px; }
.badge.valid { background: var(--ok-bg); color: var(--ok); }
.badge.invalid { background: var(--bad-bg); color: var(--bad); }
.badge.unknown { background: var(--warn-bg); color: var(--warn); }
.badge.pending { background: var(--surface-2); color: var(--muted); }
.signer-msg { margin: 6px 0 10px; font-size: 13px; color: var(--muted); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 13.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts .warn { color: var(--warn); }
.facts .bad { color: var(--bad); }
.facts .ok { color: var(--ok); }
.signer details { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.signer summary { cursor: pointer; color: var(--accent); }
.signer details p { margin: 6px 0 0; overflow-wrap: anywhere; }
.stamp {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
}
.stamp .icon { color: var(--muted); margin-top: 1px; }
.stamp-main { flex: 1; min-width: 0; }
.stamp-main strong { display: block; }
.stamp-main span { color: var(--muted); }
.disclaimer {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--muted);
}

/* ------------------------------------------------------------ Finestre e avvisi */

.modal {
  width: min(380px, calc(100% - 32px));
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgb(10 14 24 / 0.45); }
.modal h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 18px; }
.modal p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.modal p.error { color: var(--bad); }
.modal input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.busy {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgb(10 14 24 / 0.25);
}
.busy-card {
  display: grid;
  justify-items: center;
  gap: 12px;
  min-width: 240px;
  max-width: calc(100% - 32px);
  padding: 22px 26px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.busy-card p { margin: 0; text-align: center; }
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress { width: 100%; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.progress-bar { width: 0; height: 100%; background: var(--accent); transition: width 0.15s; }

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  place-items: center;
  background: rgb(35 87 209 / 0.12);
  border: 3px dashed var(--accent);
  pointer-events: none;
}
.drop-overlay > div { padding: 24px 32px; border-radius: 14px; background: var(--surface); text-align: center; box-shadow: var(--shadow); }
.drop-overlay .icon { width: 36px; height: 36px; color: var(--accent); }
.drop-overlay p { margin: 8px 0 0; font-weight: 600; }
body.dragging .drop-overlay { display: grid; }

.toast {
  position: fixed;
  z-index: 70;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: 10px;
  background: #222733;
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow);
}
.toast.error { background: var(--bad); color: #fff; }

#printContainer, #printNotice { display: none; }

/* Iframe usato per la stampa nativa del PDF (Chrome/Edge su computer). */
.print-frame {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

/* ------------------------------------------------------------ Outlook */

body.outlook .drop-card { border-style: solid; text-align: left; padding: 22px 18px 16px; }
body.outlook .drop-card .drop-icon, body.outlook .drop-card .drop-logo { display: none; }
body.outlook .drop-card h1 { margin: 0 0 4px; font-size: 18px; }
body.outlook .drop-card .drop-hint { margin: 0 0 12px; }
body.outlook .welcome { place-items: start center; }
.att-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.att-list.nested { margin: 6px 0 4px 18px; padding-left: 10px; border-left: 2px solid var(--border); }
.att-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.att-item:hover { background: var(--surface-2); }
.att-item > .icon { color: var(--muted); }
.att-item.supported > .icon { color: var(--accent); }
.att-text { display: grid; min-width: 0; }
.att-text strong { font-weight: 600; overflow-wrap: anywhere; }
.att-text span { font-size: 12.5px; color: var(--muted); }
.att-empty { padding: 6px 0; font-size: 13px; color: var(--muted); }

/* ------------------------------------------------------------ Fattura elettronica */

.view-tabs {
  display: flex;
  gap: 4px;
  max-width: 900px;
  margin: 0 auto 12px;
  padding: 4px;
  width: max-content;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.tab {
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--accent); color: var(--accent-text); }

.invoice { font-size: 14px; line-height: 1.45; }
.inv-body + .inv-body { margin-top: 36px; padding-top: 28px; border-top: 3px double #c9ced8; }
.inv-lot { margin: 0 0 6px; font-size: 12px; color: #5b6475; }
.inv-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px 24px;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 2px solid #1c2130;
}
.inv-kind { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: #2357d1; }
.inv-head h2 { margin: 2px 0 0; font-size: 22px; letter-spacing: -0.01em; }
.inv-total { text-align: right; }
.inv-total span { display: block; font-size: 12px; color: #5b6475; }
.inv-total strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 4px; }
.inv-party { padding: 12px 14px; border: 1px solid #dde1e8; border-radius: 8px; break-inside: avoid; }
.inv-parties ~ .inv-party { margin-top: 12px; }
.inv-party h3, .inv-section h3 {
  margin: 0 0 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #5b6475;
}
.inv-party-name { margin: 0 0 6px; font-size: 15px; font-weight: 650; }
.inv-facts { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 0; font-size: 13px; }
.inv-facts dt { color: #5b6475; }
.inv-facts dd { margin: 0; overflow-wrap: anywhere; }
.inv-section { margin: 20px 0 0; }
.inv-section > h3 { break-after: avoid; page-break-after: avoid; }
.inv-payment, .inv-attachment, .inv-totals { break-inside: avoid; page-break-inside: avoid; }
.inv-section > .inv-facts + .inv-facts { margin-top: 8px; }
.inv-table-wrap { overflow-x: auto; }
.inv-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.inv-table th {
  padding: 6px 8px;
  border-bottom: 1px solid #c9ced8;
  font-size: 11.5px;
  font-weight: 700;
  text-align: left;
  text-transform: uppercase;
  color: #5b6475;
}
.inv-table td { padding: 7px 8px; border-bottom: 1px solid #eceef2; vertical-align: top; }
.inv-table tr { break-inside: avoid; }
.inv-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.inv-extra { display: block; font-size: 12px; color: #5b6475; }
.inv-totals { width: min(340px, 100%); margin: 14px 0 0 auto; font-variant-numeric: tabular-nums; }
.inv-totals > div { display: flex; justify-content: space-between; gap: 16px; padding: 4px 0; }
.inv-totals > .grand { margin-top: 4px; padding-top: 8px; border-top: 2px solid #1c2130; font-size: 16px; font-weight: 700; }
.inv-totals > .grand + .grand { border-top: 0; margin-top: 0; padding-top: 2px; }
.inv-payment + .inv-payment { margin-top: 12px; }
.inv-payment-title { margin: 0 0 4px; font-weight: 600; }
.inv-payment .inv-facts + .inv-facts { margin-top: 10px; padding-top: 10px; border-top: 1px dashed #dde1e8; }
.inv-attachment { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #eceef2; }
.inv-attachment > .icon { color: #2357d1; }
.inv-attachment-main { flex: 1; min-width: 0; }
.inv-attachment-main strong { display: block; overflow-wrap: anywhere; }
.inv-attachment-main span { font-size: 12.5px; color: #5b6475; }
.inv-attachment-actions { display: flex; gap: 6px; }
.inv-attachment-actions .btn { min-height: 32px; padding: 0 10px; background: #fff; color: #1c2130; border-color: #dde1e8; }
.inv-footnote { margin: 24px 0 0; font-size: 12px; color: #5b6475; }

/* ------------------------------------------- Testo riconosciuto (OCR) */

/* Come lo strato di testo di PDF.js: invisibile, ma si seleziona e si copia. */
.ocrLayer { position: absolute; inset: 0; overflow: clip; line-height: 1; z-index: 0; color-scheme: only light; }
.ocrLayer span { position: absolute; white-space: pre; color: transparent; transform-origin: 0 0; cursor: text; font-family: sans-serif; }
/* Selezione ben visibile, sul testo vero e su quello riconosciuto. */
#viewer :is(.textLayer, .ocrLayer) ::selection { background: rgb(35 87 209 / 0.42); }
/* gli a-capo fra le righe lette stanno in colonna a sinistra: mai colorati (la regola #viewer qui sopra vincerebbe) */
#viewer :is(.textLayer, .ocrLayer) br::selection { background: transparent; }
.ocr-status {
  position: fixed;
  left: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 20;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12.5px;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.12);
  pointer-events: none;
}

/* Selezione a riquadro: pulsante attivo, o Alt + trascina. */
:is(#btnBox, #btnShot)[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.box-mode .page { cursor: crosshair; touch-action: none; }
.box-mode :is(.textLayer, .ocrLayer) { user-select: none; pointer-events: none; }
.boxSel { position: absolute; z-index: 5; border: 2px solid #2357d1; background: rgb(35 87 209 / 0.08); pointer-events: none; }
.boxMark { position: absolute; z-index: 4; background: rgb(255 200 0 / 0.45); border-radius: 2px; pointer-events: none; mix-blend-mode: multiply; }

/* Menu «Riconosci il testo» */
.ocr-wrap { position: relative; }
.ocr-menu { right: auto; left: 50%; transform: translateX(-50%); min-width: 260px; }
.share-option:disabled { opacity: 0.5; cursor: default; }

/* Che cosa è stato copiato */
.copy-pill {
  position: fixed;
  z-index: 45;
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.25);
  cursor: pointer;
}
.copy-card {
  position: fixed;
  z-index: 44;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 24px));
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--ok, #1f8a4c);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.22);
}
.copy-card.errore { border-left-color: var(--bad); }
.copy-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.copy-head span { color: var(--muted); font-size: 13px; }
.copy-card pre {
  max-height: 28vh;
  overflow: auto;
  margin: 8px 0 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  font: 13px/1.45 ui-monospace, Consolas, monospace;
  white-space: pre-wrap;
  user-select: text;
}
.copy-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.copy-card img { display: none; max-width: 100%; max-height: 32vh; margin: 8px auto 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.copy-card.shot img { display: block; }
.copy-card.shot pre, .copy-card:not(.shot) [data-a="salva"] { display: none; }
.shot-mode .boxSel { border-style: dashed; background: rgb(35 87 209 / 0.05); }

/* ------------------------------------------------------------- Firma */

.sign-dialog { width: min(560px, calc(100vw - 32px)); }
.sign-tabs { display: flex; gap: 4px; margin: 6px 0 10px; border-bottom: 1px solid var(--border); }
.sign-tab {
  padding: 8px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.sign-tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.sign-area canvas, .sign-saved {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 1;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
}
.sign-area canvas.sign-preview:not(.photo) { aspect-ratio: 4 / 1; margin-top: 10px; }
.sign-area canvas.photo { margin-top: 10px; }
.sign-pad { touch-action: none; cursor: crosshair; }
.sign-pane { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.sign-pane > .btn.subtle { align-self: flex-end; }
.modal .sign-typed { font-family: "Segoe Script", "Lucida Handwriting", "Brush Script MT", cursive; font-size: 18px; }
.modal p.sign-hint { margin: 0; }
.sign-options { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; font-size: 14px; color: var(--muted); }
.sign-colors { display: inline-flex; align-items: center; gap: 8px; }
.sign-color {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  outline: 1px solid var(--border);
  background: var(--ink);
  cursor: pointer;
}
.sign-color[aria-pressed="true"] { outline: 2px solid var(--accent); }
.sign-keep { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.modal .sign-keep input { width: auto; margin: 0; }
.sign-bar {
  position: absolute;
  left: 50%;
  top: 12px;
  z-index: 15;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 8px 8px 8px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.18);
  font-size: 14px;
}
/* Il testo alternativo delle immagini di PDF.js non serve per una firma. */
#viewer .stampEditor .altText { display: none; }

/* ------------------------------------------------------- Compilazione */

.fill-dialog { width: min(520px, calc(100vw - 32px)); }
.uscita-dialog { width: min(460px, calc(100vw - 32px)); }
.uscita-dialog .modal-actions { flex-wrap: wrap; }
.modal p.fill-doc { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.fill-label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; }
.fill-dialog textarea, .fill-dialog .fill-chi {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  resize: vertical;
}
.fill-dialog .fill-chi { margin-bottom: 14px; resize: none; }
.fill-summary { margin: 0 0 4px; font-weight: 600; }
.riassunto { display: block; font-size: 14.5px; line-height: 1.55; }
.riassunto p { margin: 10px 0 4px; }
.riassunto ul { margin: 2px 0 6px; padding-left: 20px; }
.riassunto li { margin: 3px 0; }
#sumBody .copy-actions { margin-top: 14px; }
.fill-hint { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; }
#fillPanel h3 { margin: 16px 0 6px; font-size: 14px; }
.fill-list { margin: 0; padding: 0; list-style: none; }
.fill-list li { display: flex; flex-wrap: wrap; gap: 2px 8px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.fill-list strong { flex: 1 1 100%; font-weight: 600; }
.fill-list span { overflow-wrap: anywhere; }
.fill-list em { margin-left: auto; color: var(--muted); font-style: normal; font-size: 12.5px; }
.fill-list.todo strong { color: var(--bad); }
.fill-list.todo span { color: var(--muted); }

/* ----------------------------- Anteprima di Outlook classico / Esplora file */

body.anteprima :is(#btnOpen, #btnInstall, .share-wrap, #btnWindow) { display: none !important; }
body.anteprima .ocr-wrap { display: block !important; }
body.anteprima .welcome .drop-card { display: none; }

/* Senza documento la barra non mostra i pulsanti spenti (firma, salva, stampa): niente «pulsanti morti». */
.toolbar .tb-actions .btn:disabled { display: none; }
#btnOpenBig { min-height: 48px; padding: 0 26px; font-family: "Josefin Sans", system-ui, sans-serif; font-weight: 600; }
#btnOpenBig .icon { --icon-acc: currentColor; }

/* ---------------------------------------- Barra su una riga, solo icone */

/* Le scritte dei pulsanti non si vedono più (restano nel suggerimento, «title»): così la barra
   sta su una riga (Alessandro, 29/10/2026). Solo il telefono, troppo stretto, va su due. */
.toolbar .btn-label { display: none; }
.toolbar .btn:not(.sig-chip) { width: 34px; min-height: 34px; padding: 0; }
.toolbar .btn:not(.primary) { border-color: transparent; background: transparent; }
.toolbar .btn:not(.primary):hover:not(:disabled) { background: var(--surface-2); }
@media (min-width: 761px) {
  .toolbar { flex-wrap: nowrap; gap: 10px; }
  .tb-file { flex: 1 1 0; }
  .tb-view { gap: 8px; }
  .tb-actions { gap: 2px; }
}
@media (max-width: 760px) {
  .tb-view, .tb-view .tb-cluster { flex-wrap: wrap; justify-content: center; }
  .page-box { white-space: nowrap; }
}
@media (min-width: 761px) and (max-width: 900px) {
  #zoomSelect { display: none; }
  .tb-view { gap: 4px; }
}

/* ------------------------------------------------------------ Schermi piccoli */

@media (max-width: 760px) {
  .toolbar { gap: 6px 8px; padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
  .tb-file { flex: 1 1 0; }
  .tb-view { order: 3; width: 100%; justify-content: space-between; gap: 6px; }
  .btn-label { display: none; }
  #btnOpen, .tb-actions .btn { width: 38px; padding: 0; }
  #zoomSelect { max-width: 118px; }
  .sig-chip { max-width: 46vw; }
  .drop-card { padding: 28px 20px 20px; }
  .drop-logo { width: 72px; height: 72px; }
  .drop-card h1 { font-size: 23px; margin-top: 18px; }
  .drop-hint { display: none; } /* sul telefono non si trascina */
  #btnOpenBig { width: 100%; }
  .inv-parties { grid-template-columns: 1fr; }
  .inv-head h2, .inv-total strong { font-size: 19px; }
  .sheet { padding: 16px; }
  .sig-panel {
    top: auto;
    width: 100%;
    max-height: 85%;
    border-left: 0;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    animation-name: slide-up;
  }
  @keyframes slide-up { from { transform: translateY(24px); opacity: 0; } }
}

@media (max-width: 420px) {
  .doc-title { display: none; }
  #zoomSelect { display: none; }
}

/* ------------------------------------------------------------ Stampa */

@media print {
  html, body {
    height: 100% !important;
    overflow: visible !important;
    background: #fff !important;
    display: block !important;
  }
  body > * { display: none !important; }

  body[data-print="pdf"] > #printContainer { display: block !important; height: 100%; }
  #printContainer > .printedPage {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    break-after: page;
    page-break-after: always;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  #printContainer > .printedPage:last-child { break-after: auto; page-break-after: auto; }
  #printContainer :is(img, canvas) { display: block; max-width: 100%; max-height: 100%; }

  body[data-print="alt"] > #main { display: block !important; position: static; background: none; }
  body[data-print="alt"] #main > :not(#altView) { display: none !important; }
  body[data-print="alt"] .alt-view { position: static; overflow: visible; padding: 0; }
  body[data-print="alt"] .sheet { max-width: none; padding: 0; box-shadow: none; }
  body[data-print="alt"] .sheet-note, body[data-print="alt"] .message-card,
  body[data-print="alt"] .view-tabs, body[data-print="alt"] .inv-attachment-actions { display: none !important; }
  body[data-print="alt"] .inv-table-wrap { overflow: visible; }
  body[data-print="alt"] .image-view { max-height: 100vh; object-fit: contain; box-shadow: none; }

  body:not([data-print]) > #printNotice { display: block !important; padding: 2cm; font: 16px system-ui, sans-serif; }
}

/* Pulsantino accanto alla selezione: Copia · Sottolinea · Spiega */
.copy-pill { display: flex; gap: 0; padding: 0; overflow: hidden; }
.copy-pill button { font: inherit; color: inherit; background: none; border: 0; padding: 6px 12px; cursor: pointer; }
.copy-pill button + button { border-left: 1px solid rgba(255, 255, 255, 0.3); }
.copy-pill button:hover { background: rgba(255, 255, 255, 0.15); }
.copy-actions .btn[hidden] { display: none !important; }
.viewer-container.underline-mode .textLayer { cursor: text; }
.viewer-container.underline-mode .textLayer ::selection { background: rgba(164, 22, 26, 0.25); }

/* Link della pagina iniziale nel colore del testo, non il blu predefinito. */
.drop-card a { color: var(--text); text-decoration-color: var(--border); text-underline-offset: 3px; }
.drop-card a:hover { text-decoration-color: currentColor; }

/* Firma e note col dito (iPad): il trascinamento sposta l'elemento invece di scorrere la pagina,
   e le maniglie per ridimensionare si prendono anche col dito (prima 6 px). */
#viewer .annotationEditorLayer :is(.stampEditor, .freeTextEditor, .resizer) { touch-action: none; }
@media (pointer: coarse) {
  #viewer .annotationEditorLayer { --resizer-size: 18px; }
  #viewer .annotationEditorLayer .resizer:is(.topMiddle, .bottomMiddle, .middleLeft, .middleRight) { display: none; }
}

/* Tema scuro: i pulsanti pieni restano del cremisi del logo, con la scritta bianca (prima rosa #ef8a8c,
   «un rosso diverso»). Il rosa resta per testi e contorni, che sul fondo scuro devono leggersi. */
@media (prefers-color-scheme: dark) {
  .btn.primary, .copy-pill { background: #a4161a; border-color: #a4161a; color: #fff; --icon-acc: currentColor; }
  .btn.primary:hover:not(:disabled) { background: #bf2227; border-color: #bf2227; }
}

/* Mentre si sistema la firma: niente selezione del testo né menu di iPadOS sotto il dito. */
.viewer-container.sign-mode :is(.textLayer, .ocrLayer) { -webkit-user-select: none; user-select: none; pointer-events: none; }
.viewer-container.sign-mode .stampEditor { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* ------------------------------------------------ Barra a gruppi (29/10/2026) */
/* Ogni gruppo in una «pillola» grigia: le icone si distinguono e si trovano (pareri di GPT, Gemini,
   DeepSeek e Grok). Icone 22 px a tratto pieno; passaggio del mouse e stato attivo in cremisi chiaro. */
:root { --tb-pill: #eef0f3; --tb-hover: rgb(164 22 26 / 0.10); --tb-on: rgb(164 22 26 / 0.16); }
@media (prefers-color-scheme: dark) { :root { --tb-pill: #2c3038; --tb-hover: rgb(239 138 140 / 0.14); --tb-on: rgb(239 138 140 / 0.24); } }
.toolbar { min-height: 58px; }
.toolbar .tb-cluster { gap: 2px; padding: 3px; border-radius: 10px; background: var(--tb-pill); }
.toolbar .tb-actions .tb-cluster:not(:has(> :not([hidden], .btn:disabled))) { display: none; }
.toolbar .tb-actions { display: flex; gap: 10px; }
.toolbar .tb-view { gap: 10px; }
.toolbar .btn:not(.sig-chip) { width: 38px; min-height: 38px; border-radius: 8px; }
.toolbar .btn .icon { width: 24px; height: 24px; stroke-width: 1.8; }
.toolbar .btn:not(.primary):hover:not(:disabled) { background: var(--tb-hover); }
.toolbar .btn[aria-pressed="true"], .toolbar .btn[aria-expanded="true"] { background: var(--tb-on); }
.toolbar .page-box input, .toolbar #zoomSelect { background: var(--surface); border-color: transparent; }
.toolbar #btnOpen { background: var(--tb-pill); }
@media (min-width: 1000px) {
  .toolbar { flex-wrap: nowrap; }
}
@media (max-width: 1240px) {
  #zoomSelect { display: none; }
}
@media (min-width: 761px) and (max-width: 999px) {
  .toolbar { flex-wrap: wrap; row-gap: 8px; }
  .tb-file { flex: 1 1 auto; }
  .tb-view { order: 3; width: 100%; justify-content: center; }
}

/* ------------------------------------------- Pannello accanto al PDF (29/10/2026) */
/* Con un pannello aperto il PDF si restringe e resta visibile: a destra su schermi larghi,
   nella metà bassa su iPad in verticale e telefono. */
:root { --pannello: min(440px, 40vw); }
body.panel-open .sig-panel { box-shadow: none; animation: none; }
@media (min-width: 761px) and (orientation: landscape), (min-width: 1100px) {
  body.panel-open .sig-panel { width: var(--pannello); }
  body.panel-open .viewer-container { right: var(--pannello); }
}
@media (max-width: 1099px) and (orientation: portrait), (max-width: 760px) {
  body.panel-open .sig-panel {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%; height: 50%; max-height: 50%;
    border-left: 0; border-top: 1px solid var(--border); border-radius: 14px 14px 0 0;
  }
  body.panel-open .viewer-container { bottom: 50%; }
}

/* Menu dopo la selezione: va a capo se lo schermo è stretto (telefono). */
.copy-pill { flex-wrap: wrap; max-width: calc(100vw - 16px); border-radius: 14px; }

/* «A nome di chi?» nella finestra Compila */
.fill-who { margin: 0 0 14px; padding: 0; border: 0; }
.fill-who-opt { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.fill-who-opt + .fill-who-opt { margin-top: 6px; }
.fill-who-opt:has(input:checked) { border-color: var(--accent); background: var(--tb-hover, rgb(164 22 26 / 0.08)); }
.fill-who-opt input { flex: none; width: 17px; height: 17px; min-height: 0; margin: 2px 0 0; padding: 0; accent-color: #a4161a; }
.fill-who-opt span { flex: 1; display: grid; gap: 1px; text-align: left; }
.fill-who-opt small { color: var(--muted); font-size: 12.5px; }

/* Firma in una schermata sola, senza schede (30/10/2026) */
.sign-saved-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 10px; }
.sign-saved-pick { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; padding: 6px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.sign-saved-pick[aria-pressed="true"] { border-color: var(--accent); background: var(--tb-hover, rgb(164 22 26 / 0.08)); }
.sign-saved-pick img.sign-saved { height: 44px; max-width: 55%; object-fit: contain; background: #fff; border-radius: 6px; }
.sign-pad-wrap { position: relative; }
.sign-pad-hint { position: absolute; inset: 0; display: none; place-items: center; color: var(--muted); font-size: 14px; pointer-events: none; }
.sign-pad-wrap.vuoto .sign-pad-hint { display: grid; }
.sign-alt { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.sign-alt .sign-typed { flex: 1 1 220px; min-width: 0; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 15px; }
.sign-alt .btn { min-height: 40px; }
.sign-pad-wrap canvas.sign-pad { display: block; width: 100%; aspect-ratio: 3 / 1; border: 1px dashed var(--border); border-radius: 8px; background: #fff; }
.sign-saved-pick img.sign-saved { width: auto; aspect-ratio: auto; border: 0; }
@media (max-width: 500px) {
  .sign-dialog h2 { margin-bottom: 6px; }
  .sign-alt .sign-typed { flex-basis: 100%; }
}

/* Riepilogo della compilazione: per ogni dato mancante «Lo scrivo io» / «Cercalo» */
.fill-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.fill-actions .btn { min-height: 32px; padding: 0 10px; font-size: 13.5px; }
.fill-found { display: grid; gap: 3px; margin-top: 6px; font-size: 13.5px; }
.fill-found:empty { display: none; }
.fill-found small { color: var(--muted); }
.fill-found .btn { justify-self: start; min-height: 30px; padding: 0 10px; font-size: 13px; }
.fill-value { font-family: "Courier New", Courier, monospace; color: #0038c7; font-weight: 600; }
.fill-wait { color: var(--muted); font-style: italic; }
.fill-ok { color: var(--ok); font-weight: 600; font-size: 13px; }

/* «Aggiorna»: compare solo quando c'è una versione nuova e resta finché non si preme */
#btnUpdate.c-e-nuova { background: var(--accent) !important; color: #fff; --icon-acc: #fff; animation: aggiorna-pulsa 2.4s ease-in-out infinite; }
@keyframes aggiorna-pulsa { 0%, 100% { box-shadow: 0 0 0 0 rgb(164 22 26 / 0.45); } 50% { box-shadow: 0 0 0 7px rgb(164 22 26 / 0); } }
@media (prefers-reduced-motion: reduce) { #btnUpdate.c-e-nuova { animation: none; } }

/* Pagina iniziale: «Prova con un esempio» */
.esempi { margin: 18px 0 4px; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); text-align: center; }
.esempi-titolo { margin: 0 0 10px; font-family: "Josefin Sans", system-ui, sans-serif; font-weight: 600; font-size: 15px; }
.esempi-lista { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.esempi-lista .btn { background: var(--surface); }
.esempi-lista { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.esempi-lista .btn { font-size: 13px; padding: 7px 11px; justify-content: flex-start; text-align: left; line-height: 1.25;
  white-space: normal; height: auto; min-height: 36px; min-width: 0; }
.esempi-lista .btn span { min-width: 0; overflow-wrap: anywhere; }
.esempi-nota .icon { width: 14px; height: 14px; vertical-align: -2px; }
.esempi-nota { margin: 10px 0 0; color: var(--muted); font-size: 12.5px; }
body.outlook .esempi { display: none; }

/* Il campo appena scritto o cercato dal pannello «Da completare» */
.annotationLayer .campo-evidenziato { outline: 3px solid #e8a33d !important; outline-offset: 2px; transition: outline-color .4s; }
.fill-scrivi { display: flex; gap: 6px; margin-top: 6px; }
.fill-scrivi input { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; }
.fill-salva { margin: 12px 0 4px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.fill-salva p { margin: 0 0 8px; font-size: 14px; }
.fill-salva .modal-actions { justify-content: flex-start; margin-top: 0; }

/* «I miei dati» dei colleghi */
.miei-dialog { width: min(560px, calc(100vw - 32px)); }
.miei-campi { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.miei-campi label, .miei-altro { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.miei-altro { margin-top: 10px; }
.miei-campi input, .miei-altro textarea { padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; }
@media (max-width: 520px) { .miei-campi { grid-template-columns: 1fr; } }
.fill-miei { margin-top: 6px; }

/* Accesso alla cassaforte aziendale */
.cf-dialog { width: min(440px, calc(100vw - 32px)); }
.cf-campo { display: flex; flex-direction: column; gap: 3px; margin: 8px 0; font-size: 13px; }
.cf-campo input, .cf-select { padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 15px; width: 100%; }
.cf-errore { min-height: 1.3em; margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.cf-dialog .modal-actions, .miei-dialog .modal-actions { flex-wrap: wrap; }
.miei-dialog .cf-esci { margin-right: auto; }

/* Dati delicati della Vinicola cambiati nella cassaforte aziendale */
.fill-avviso { margin: 8px 0 12px; padding: 10px 12px; border-radius: 10px; border: 1px solid #A4161A;
  background: color-mix(in srgb, #A4161A 10%, var(--surface)); color: var(--text); font-size: 14px; }
.fill-avviso p { margin: 6px 0 0; }

/* «Ruota» su una scansione storta (30/10/2026): gira l'immagine e i campi compilati, non il testo (già letto sulla
   pagina raddrizzata), né le sottolineature, le note e le firme. Il livello del testo letto torna storto finché la
   pagina non è raddrizzata: --ocr è il contrario dell'angolo con cui è stata letta. */
.page[data-raddrizza] .canvasWrapper,
.page[data-raddrizza] .annotationLayer[data-main-rotation="0"] { transform: rotate(var(--raddrizza)); transform-origin: 50% 50%; }
.ocrLayer { transform: rotate(calc(var(--raddrizza, 0deg) + var(--ocr, 0deg))); transform-origin: 50% 50%; }
