/* Font autoospitato: garantisce che l'anteprima (browser dell'utente) e il PDF
   generato dal server (Puppeteer) usino esattamente lo stesso font, con le
   stesse metriche di testo. Se il font dipendesse da quelli installati sul
   sistema, server e client potrebbero usare fallback diversi (es. il server
   Linux non ha "Inter"/"Segoe UI" installati) e la paginazione calcolata nel
   browser non corrisponderebbe più a quella del PDF esportato. */
@font-face {
  font-family: "Inter";
  src: url("/fonts/Inter-VF.ttf") format("truetype-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: block;
}

:root {
  --ink: #172531;
  --muted: #667784;
  --line: #dce4e7;
  --paper: #ffffff;
  --background: #f4f7f5;
  --teal: #e25c25;
  --teal-dark: #bd481b;
  --teal-soft: #fde9e0;
  --sand: #fbf4e6;
  --shadow: 0 18px 42px rgba(20, 39, 46, 0.08);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  background: var(--background);
}

.topbar {
  height: 72px;
  padding: 0 clamp(20px, 5vw, 52px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 750;
  letter-spacing: 0.045em;
}

/* Logo istituzionale: sorgente 2066x365, resa a 38px di altezza */
.brand-logo {
  display: block;
  height: 38px;
  width: auto;
  max-width: 100%;
  flex: none;
  object-fit: contain;
}

/* Sistemi Palermo: la scritta PALERMO sotto il marchio chiede un filo di altezza in piu' */
.brand-logo--sistemi {
  height: 40px;
}

.brand-sep {
  width: 1px;
  height: 30px;
  flex: none;
  background: var(--line);
}

/* Con due loghi la barra si stringe: recupero spazio sulle voci di menu */
@media (max-width: 1500px) {
  .brand-logo {
    height: 32px;
  }
  .brand-logo--sistemi {
    height: 34px;
  }
  .topbar-link {
    padding: 8px 11px;
  }
}

@media (max-width: 700px) {
  .brand-logo {
    height: 26px;
  }
  .brand-logo--sistemi {
    height: 28px;
  }
  .brand-sep {
    height: 22px;
  }
}

.brand-mark {
  height: 38px;
  width: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--teal);
  color: white;
  letter-spacing: 0;
}

.badge {
  padding: 9px 14px;
  border-radius: 999px;
  color: var(--teal-dark);
  background: var(--teal-soft);
  font-size: 0.9rem;
  font-weight: 600;
}

.layout {
  max-width: 1780px;
  margin: 0 auto;
  padding: 44px clamp(18px, 3.5vw, 44px);
  display: grid;
  grid-template-columns: minmax(480px, 580px) minmax(794px, 1fr);
  gap: 32px;
  align-items: start;
}

.intro {
  margin-bottom: 34px;
}

.eyebrow {
  color: var(--teal);
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-weight: 700;
  font-size: 0.75rem;
  margin: 0 0 12px;
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 3vw, 2.45rem);
  letter-spacing: -0.045em;
}

.intro > p:last-child {
  color: var(--muted);
  margin: 0;
}

.product-import {
  margin-bottom: 35px;
  padding: 25px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 18px;
}

.product-import summary {
  cursor: pointer;
  color: var(--teal-dark);
  font-weight: 700;
}

.product-import[open] summary {
  margin-bottom: 20px;
}

.product-import .section-heading {
  margin-bottom: 19px;
}

.product-import .eyebrow {
  margin-bottom: 7px;
}

.import-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(185px, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.import-form input[type="file"] {
  padding: 9px 10px;
  font-size: 0.84rem;
}

.import-format {
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.5;
}

.product-import .feedback:empty {
  display: none;
}

.products {
  display: grid;
  gap: 16px;
  margin-top: 19px;
}

.empty-products {
  color: var(--muted);
  background: var(--sand);
  border-radius: 10px;
  padding: 14px;
  margin: 0;
  font-size: 0.9rem;
}

.product-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.product-card h3 {
  margin: 16px 16px 4px;
  font-size: 1rem;
}

.product-meta {
  margin: 0 16px 15px;
  color: var(--muted);
  font-size: 0.82rem;
}

.product-modules {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.product-modules thead {
  background: #faf5f2;
  color: #5b4b43;
}

.product-modules th,
.product-modules td {
  padding: 9px 10px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.product-modules td:first-child {
  white-space: nowrap;
  font-weight: 600;
}

.product-modules .area-row th {
  padding: 11px 10px;
  border-top: 1px solid #f0b69e;
  color: var(--teal-dark);
  background: var(--teal-soft);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.included,
.excluded {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 650;
  white-space: nowrap;
}

.included {
  color: var(--teal-dark);
  background: var(--teal-soft);
}

.excluded {
  color: var(--muted);
  background: #edf1f2;
}

.optional {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 999px;
  color: #745728;
  background: #fcf0d8;
  font-size: 0.7rem;
  font-weight: 650;
  white-space: nowrap;
}

.configuration {
  margin: 0 0 35px;
  padding: 26px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 18px;
}

/* ─── Selettore multi-prodotto ───────────────────────────────────────────── */

.multi-product-selector {
  margin-bottom: 18px;
}

.multi-product-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 8px;
}

.multi-product-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.multi-product-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  user-select: none;
}

.multi-product-btn:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.multi-product-btn--active {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.multi-product-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid currentColor;
  flex-shrink: 0;
  transition: background 0.15s;
}

.multi-product-btn--active .multi-product-dot {
  background: var(--teal);
  border-color: var(--teal);
}

/* Separa visivamente le card quando ci sono più prodotti */
.job-card + .job-card {
  margin-top: 20px;
}

/* Pulsante rimuovi prodotto (visibile solo in multi-prodotto) */
.product-card-remove {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--background);
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  z-index: 1;
}

.product-card-remove:hover {
  border-color: #c62828;
  color: #c62828;
  background: #fff5f5;
}

/* ─────────────────────────────────────────────────────────────────────────── */

.job-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  overflow: hidden;
}

.job-header {
  padding: 22px 26px 16px;
  position: relative;
  border-bottom: 1px solid var(--line);
}

.job-header h3 {
  margin: 0 0 4px;
  font-size: 1.35rem;
}

.job-header .eyebrow {
  margin-bottom: 6px;
}

.edition-selector {
  margin: 18px 26px 0;
  padding: 14px;
  border-radius: 12px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.edition-selector legend {
  font-size: 0.9rem;
}

.edition-choice {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
}

.edition-choice:has(input:checked) {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.edition-choice input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  grid-row: span 2;
  accent-color: var(--teal);
}

.edition-choice small {
  color: var(--muted);
}

.packages-divider {
  grid-column: 1 / -1;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 10px 0 4px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}

.sir-tier-list {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
}
.sir-tier-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.1s;
}
.sir-tier-item:first-child { border-top: none; }
.sir-tier-item:hover { background: var(--paper-alt, #f6f8fa); }
.sir-tier-item--active { background: var(--teal-soft); }
.sir-tier-item input[type="radio"] {
  flex-shrink: 0;
  accent-color: var(--teal);
}
.sir-tier-price {
  margin-left: auto;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--teal-dark);
  white-space: nowrap;
}

.extra-config-choice {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
  margin-bottom: 8px;
}

.extra-config-choice small {
  color: var(--muted);
  font-size: 0.78rem;
}

.extra-config-choice:has(input:checked) {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.extra-config-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
  cursor: pointer;
}

.module-selector {
  padding: 20px 26px 26px;
  border-top: 1px solid var(--line);
  margin-top: 20px;
}

.module-selector-heading {
  margin-bottom: 16px;
}

.module-selector-heading h4 {
  margin: 0 0 4px;
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}

.module-selector-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

/* Sezione moduli inclusi */
.included-section {
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
  margin-bottom: 20px;
}

.included-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #f0faf8;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--teal-dark);
  border-bottom: 1px solid var(--line);
}

.included-count {
  background: var(--teal);
  color: #fff;
  border-radius: 20px;
  padding: 1px 9px;
  font-size: 0.75rem;
  font-weight: 700;
}

.included-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 14px;
}

.included-chip {
  background: #e8f5f2;
  color: var(--teal-dark);
  border: 1px solid #b8ddd6;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.78rem;
}

/* Sezione aree integrative */
.areas-section {
  margin-top: 4px;
}

.areas-section-heading {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 4px 2px 10px;
}

.module-area {
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
}

.module-area-header {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--teal-soft);
  padding: 9px 13px;
}

.module-area-header h4 {
  margin: 0;
  color: var(--teal-dark);
  font-size: 0.82rem;
  flex: 1;
}

.area-checkbox {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--teal);
}

.module-option {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.module-option.is-included {
  cursor: default;
}

.module-identity {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.84rem;
}

.module-identity small {
  color: var(--muted);
}

.edition-price {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
}

.edition-price strong {
  font-size: 0.95rem;
  color: var(--teal-dark);
}

.edition-price small {
  font-size: 0.75rem;
  color: var(--muted);
}

.module-option {
  display: flex;
}

.module-price {
  display: flex;
  flex-direction: row;
  gap: 12px;
  align-items: center;
  text-align: right;
  margin-left: auto;
  margin-right: 10px;
  flex-shrink: 0;
}

.module-price-licenza,
.module-price-canone {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.module-price-licenza {
  color: var(--muted);
}

.module-price-canone {
  color: var(--teal-dark);
}

.optional-control {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 650;
}

.optional-control input {
  width: 17px;
  height: 17px;
  margin: 0 5px 0 0;
  accent-color: var(--teal);
}

fieldset {
  min-width: 0;
  margin: 0 0 35px;
  padding: 26px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 18px;
}

legend {
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0 7px;
}

.customer > .fieldset-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 19px;
}

.document-settings > .fieldset-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 19px;
}

.collapsible > legend {
  width: 100%;
}

.collapse-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0;
  background: none;
  border: none;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.collapse-toggle:hover {
  color: var(--teal-dark);
}

.collapse-toggle:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
  border-radius: 4px;
}

.chevron {
  display: inline-block;
  color: var(--muted);
  font-size: 0.85em;
  transition: transform 0.22s ease;
}

.collapsible.collapsed .chevron {
  transform: rotate(-90deg);
}

.collapsible.collapsed .fieldset-body {
  display: none;
}

.collapsible.collapsed {
  padding-bottom: 0;
  margin-bottom: 20px;
}

.logos-field,
.description-field,
.footer-config-field {
  grid-column: 1 / -1;
}

.footer-config-field h3 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 0.95rem;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.footer-global-label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--ink) !important;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 14px !important;
}

.footer-config-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--line) !important;
  border-radius: 4px !important;
  padding: 0 !important;
  background: #fff !important;
  accent-color: var(--teal);
  cursor: pointer;
  flex-shrink: 0;
}

.footer-config-row {
  margin-bottom: 12px;
}

.footer-config-align-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.footer-align-btns {
  display: flex;
  gap: 6px;
}

.footer-align-btn {
  padding: 5px 14px;
  border: 1.5px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font: inherit;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}

.footer-align-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.footer-align-btn--active {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-weight: 700;
}

.footer-config-field label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.footer-config-field input,
.footer-config-field textarea {
  font: inherit;
  font-size: 0.88rem;
  color: var(--ink);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
  resize: vertical;
}

.footer-config-field input:focus,
.footer-config-field textarea:focus {
  outline: none;
  border-color: var(--teal);
}

.document-description {
  margin: 0 0 22px;
  color: #43535f;
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-line;
}

.document-description:empty {
  display: none;
}

.logos-field h3 {
  margin: 0 0 5px;
  color: var(--ink);
  font-size: 0.95rem;
}

.logos-field > p {
  margin: 0 0 13px;
  color: var(--muted);
  font-size: 0.78rem;
}

.logo-controls {
  display: grid;
  gap: 9px;
}

.logo-row {
  display: grid;
  grid-template-columns: 54px minmax(150px, 1fr) 102px 98px;
  gap: 9px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.logo-row > strong {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.78rem;
}

.logo-row > strong small {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 500;
}

.logo-row .logo-file {
  min-width: 0;
  padding: 8px;
  font-size: 0.75rem;
}

.logo-position {
  width: 100%;
  padding: 9px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
}

.logo-size {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 6px;
  color: var(--muted);
  font-size: 0.7rem;
}

.logo-size .logo-size-value {
  grid-column: 1 / -1;
  padding: 0;
  accent-color: var(--teal);
}

.logo-size output {
  color: var(--teal-dark);
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #43535f;
  font-size: 0.9rem;
  font-weight: 550;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 12px 13px;
  color: var(--ink);
  font: inherit;
  font-weight: 450;
  transition: border-color 0.18s, box-shadow 0.18s;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(226, 92, 37, 0.16);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 17px;
}

.section-heading .collapse-toggle {
  width: auto;
  font-size: 1.1rem;
  justify-content: flex-start;
  gap: 6px;
}

h2 {
  margin: 0;
  font-size: 1.25rem;
}

.section-heading span {
  color: var(--muted);
  font-size: 0.88rem;
}

.services {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
}

.service {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 16px;
  padding: 19px;
  min-height: 176px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  cursor: pointer;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.service.selected {
  border-color: var(--teal);
  box-shadow: 0 0 0 1px var(--teal);
}

.service-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.service input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
  padding: 0;
}

.category {
  color: var(--teal-dark);
  background: var(--teal-soft);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 650;
}

.service h3 {
  margin: 2px 0 0;
  font-size: 1rem;
}

.service p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
  font-size: 0.85rem;
  flex: 1;
}

.service-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 700;
}

.quantity {
  width: 54px;
  padding: 6px;
  text-align: center;
  border-radius: 8px;
}

.summary {
  grid-column: 1;
  border-radius: 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 27px;
}

.empty-summary {
  color: var(--muted);
  background: var(--sand);
  border-radius: 10px;
  padding: 15px;
  font-size: 0.9rem;
  margin: 22px 0;
}

.summary-items {
  margin-top: 22px;
}

.summary-configuration {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 14px;
  margin-bottom: 17px;
  border-radius: 10px;
  background: var(--teal-soft);
}

.summary-configuration small {
  color: var(--teal-dark);
}

.summary-line {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 12px;
  row-gap: 3px;
  margin-bottom: 15px;
  font-size: 0.91rem;
}

.summary-line small {
  color: var(--muted);
}

.summary-line strong {
  grid-row: span 2;
  font-size: 0.9rem;
}

.summary-line .optional {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.summary-price {
  display: flex;
  flex-direction: column;
  gap: 1px;
  text-align: right;
}

.summary-price strong {
  font-size: 0.83rem;
  color: var(--teal-dark);
  white-space: nowrap;
}

.summary-price small {
  font-size: 0.74rem;
  color: var(--muted);
  white-space: nowrap;
}

.summary-totals {
  border-top: 1px solid var(--line);
  padding: 14px 0 4px;
  margin-top: 6px;
  display: grid;
  gap: 8px;
}

.summary-totals-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.88rem;
}

.summary-totals-row > span {
  color: var(--muted);
}

.summary-totals-total {
  border-top: 1px dashed var(--line);
  padding-top: 8px;
  margin-top: 2px;
}

.summary-totals-total > span {
  font-weight: 700;
  color: var(--ink);
}

.summary-totals-total .summary-price strong {
  font-size: 0.92rem;
}

.adjustments {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 18px 0;
  margin-top: 17px;
}

.adjustments input {
  padding: 9px;
}

.totals {
  padding: 0;
  margin: 0 0 21px;
}

.totals div {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  color: var(--muted);
}

.totals dd {
  margin: 0;
}

.totals .grand-total {
  margin-top: 9px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 700;
}

.notes {
  margin-bottom: 19px;
}

.pricing-show-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 16px;
  cursor: pointer;
}

.pricing-show-toggle input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--teal);
  cursor: pointer;
}

textarea {
  resize: vertical;
}

.quote-actions {
  display: grid;
  gap: 10px;
}

.save-button,
.print-button,
.secondary-button,
.import-button {
  width: 100%;
  border: 0;
  border-radius: 11px;
  padding: 15px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.save-button,
.print-button,
.import-button {
  color: white;
  background: var(--teal);
}

.save-button:hover,
.print-button:hover,
.import-button:hover {
  background: var(--teal-dark);
}

.secondary-button {
  color: var(--teal-dark);
  background: var(--teal-soft);
}

.secondary-button:hover {
  background: #f9d6c7;
}

.save-button:disabled,
.import-button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.feedback {
  min-height: 20px;
  margin: 16px 0 0;
  font-size: 0.92rem;
  color: var(--teal-dark);
}

.feedback.error {
  color: #a32929;
}

.loading {
  color: var(--muted);
}

.live-preview {
  grid-column: 2;
  grid-row: 1 / span 2;
  position: sticky;
  top: 20px;
  min-width: 0;
  overflow-anchor: none;
  overflow-x: auto;
}

.preview-toolbar {
  max-width: 210mm;
  margin: 0 auto 4px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.preview-toolbar .eyebrow {
  margin-bottom: 6px;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar-actions button {
  width: auto;
  min-width: 0;
}

.save-draft-button,
.new-quote-button {
  border: 0;
  border-radius: 11px;
  padding: 15px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.save-draft-button {
  color: white;
  background: var(--teal);
}

.save-draft-button:hover {
  background: var(--teal-dark);
}

.new-quote-button {
  color: var(--teal-dark);
  background: var(--teal-soft);
}

.new-quote-button:hover {
  background: #f9d6c7;
}

.draft-feedback {
  max-width: 210mm;
  margin: 0 auto 12px;
  text-align: right;
  min-height: 20px;
}

.a4-sheet {
  /* Larghezza SEMPRE fissa a 210mm: la paginazione JS misura le altezze in base
     alla larghezza effettiva del foglio, quindi deve corrispondere esattamente
     a quella usata da Puppeteer in fase di esportazione PDF, indipendentemente
     dalla larghezza della finestra del browser. Su schermi stretti il
     contenitore .live-preview scrolla orizzontalmente invece di rimpicciolire
     il foglio. */
  width: 210mm;
  height: 297mm;
  overflow: hidden;
  margin: 0 auto;
  padding: 22mm 22mm 18mm;
  background: white;
  box-shadow: 0 9px 32px rgba(21, 37, 48, 0.16);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow-anchor: none;
}

.a4-sheet-extra {
  margin-top: 28px;
}

/* Su schermo la struttura tabella è invisibile: layout invariato.
   Usiamo > su ogni livello per non toccare le tabelle annidate (es. doc-pricing-table) */
.a4-print-table,
.a4-print-table > thead,
.a4-print-table > tbody,
.a4-print-table > thead > tr,
.a4-print-table > tbody > tr,
.a4-print-table > thead > tr > td {
  display: contents;
}

/* Il corpo diventa un flex-item che occupa tutto lo spazio tra intestazione e piè di pagina.
   overflow:hidden fa sì che il footer rimanga sempre ancorato in fondo, anche prima che
   la paginazione nasconda il contenuto in eccesso. */
.a4-print-table > tbody > tr > td {
  display: block;
  min-height: 0;
  overflow: hidden;
  padding-top: 14px;
}

.document-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding-bottom: 25px;
  border-bottom: 2px solid var(--teal);
}

.document-logos-side {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.document-logos-side strong {
  display: block;
  letter-spacing: 0.06em;
}

.document-logos-side img {
  display: block;
  flex: 0 1 auto;
  min-width: 0;
  width: calc(var(--logo-base, 150px) * var(--logo-scale, 1));
  max-width: 100%;
  max-height: 70mm;
  height: auto;
  object-fit: contain;
  object-position: left center;
}

/* Logo istituzionale: misura base propria, il 100% corrisponde al vecchio 155% */
.document-logos-side img.logo-softwarein {
  --logo-base: 221px;
}

.document-logos-right {
  justify-content: flex-end;
}

.document-logos-right img {
  object-position: right center;
}

.document-offer {
  text-align: left;
}

.document-offer p {
  margin: 0;
  color: var(--ink);
  font-weight: 650;
  font-size: 1rem;
  padding-top: 4px;
}

.document-recipient p {
  color: var(--muted);
}

.document-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 32px;
  padding: 29px 0 32px;
}

.document-details p {
  margin: 4px 0;
  color: #43535f;
}

.document-details strong {
  font-size: 1.05rem;
}

.document-recipient {
  text-align: right;
}

.document-label {
  color: var(--teal-dark) !important;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 9px !important;
}

.document-offer {
  min-width: 160px;
}

.document-items {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.document-items thead {
  color: white;
  background: var(--teal);
}

.document-items th {
  padding: 13px 12px;
  text-align: left;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.document-items td {
  padding: 15px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.document-items td strong {
  display: block;
  margin-bottom: 5px;
}

.document-items td small {
  display: block;
  max-width: 310px;
  color: var(--muted);
  line-height: 1.35;
}

.document-items .document-empty {
  padding: 26px 12px;
  color: var(--muted);
  text-align: center;
}

.document-items .number {
  text-align: right;
  white-space: nowrap;
}

.document-configuration {
  margin-bottom: 29px;
}

.document-configuration h3 {
  margin: 0 0 7px;
  font-size: 1.18rem;
}

#document-optionals {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.document-config-price {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.config-price-chip {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 0.78rem;
  line-height: 1.3;
}

.config-price-chip .config-price-lbl {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
}

.config-price-chip strong {
  font-size: 1rem;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.config-price-chip strong small {
  font-size: 0.72rem;
  font-weight: 600;
  opacity: 0.75;
}

.config-price-lic {
  background: var(--teal-soft);
  color: var(--teal-dark);
  border: 1px solid rgba(0,150,136,.18);
}

.config-price-canone {
  background: #f0f4ff;
  color: #2a3a8a;
  border: 1px solid rgba(42,58,138,.14);
}

.document-modules {
  display: grid;
  gap: 12px;
}

.document-module-area {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  break-inside: avoid;
}

.document-module-area h4 {
  margin: 0;
  padding: 8px 10px;
  color: var(--teal-dark);
  background: var(--teal-soft);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.doc-area-pkg-price {
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  color: var(--teal-dark);
}

.document-module-area ul {
  list-style: none;
  margin: 0;
  padding: 5px 10px;
}

.document-module-area li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0 12px;
  align-items: baseline;
  padding: 5px 0;
  color: #43535f;
  font-size: 0.76rem;
}

.doc-module-licenza,
.doc-module-canone {
  white-space: nowrap;
  font-size: 0.73rem;
  font-weight: 600;
  text-align: right;
}

.doc-module-licenza {
  color: var(--muted);
}

.doc-module-canone {
  color: var(--teal-dark);
}

.document-empty {
  color: var(--muted);
  text-align: center;
  padding: 22px;
}

.document-bottom {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  margin-top: 32px;
}

.document-pricing-section {
  margin-top: 28px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.document-pricing-section > .document-label {
  margin: 0;
  padding: 8px 14px;
  background: var(--teal-soft);
  border-bottom: 1.5px solid var(--line);
  color: var(--teal-dark);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.document-pricing-empty {
  margin: 0;
  padding: 12px 14px;
  color: var(--muted);
  font-size: 0.82rem;
}

.doc-pricing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.76rem;
}

.doc-pricing-table thead th {
  padding: 6px 14px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.doc-pricing-table thead th:not(:first-child) {
  text-align: right;
}

.doc-pricing-table tbody td {
  padding: 5px 14px;
  border-top: 1px solid var(--line);
  color: #43535f;
}

.doc-pricing-table tbody td:not(:first-child) {
  text-align: right;
  white-space: nowrap;
}

.doc-pricing-config-row td {
  font-weight: 650;
  color: var(--teal-dark);
  background: #f0faf9;
}

.doc-pricing-extra-row td {
  font-weight: 600;
  color: var(--ink);
  background: #f8f8f8;
}

.doc-pricing-servizi-row td {
  font-weight: 600;
  color: #5a4e00;
  background: #fffae8;
}

.doc-pricing-table tbody .doc-pricing-nosconto-row td {
  font-style: italic;
  color: var(--muted);
}

.doc-pricing-table tfoot .doc-pricing-nosconto-row td {
  border-top: none;
  font-weight: 500;
  font-style: italic;
  font-size: 0.74rem;
  background: #f8f8f8;
  color: var(--muted);
  padding: 4px 14px;
}

.doc-pricing-table tfoot td {
  padding: 7px 14px;
  border-top: 2px solid var(--teal);
  font-weight: 750;
  color: var(--ink);
  background: #f0faf9;
}

.doc-pricing-table tfoot td:not(:first-child) {
  text-align: right;
  white-space: nowrap;
  color: var(--teal-dark);
}

.doc-pricing-table tfoot .doc-pricing-lordo td {
  border-top: 1px solid var(--line);
  font-weight: 600;
  background: #f8f8f8;
  color: var(--muted);
}

.doc-pricing-table tfoot .doc-pricing-sconto-row td {
  border-top: none;
  font-weight: 500;
  font-size: 0.74rem;
  background: #fff8f0;
  color: #b45309;
  padding: 4px 14px;
}

.doc-pricing-table tfoot .doc-pricing-netto td {
  border-top: 2.5px solid var(--teal);
  font-weight: 800;
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.doc-pricing-table tfoot .doc-pricing-netto td:not(:first-child) {
  color: var(--teal-dark);
}

/* ─── Multi-prodotto: separatori nel riepilogo e nel documento ───────────── */

.summary-product-hdr {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 10px 0 4px;
  border-top: 1px solid var(--line);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.summary-product-hdr:first-child {
  border-top: none;
  margin-top: 0;
}

.summary-edition-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.summary-grand-total {
  border-top: 2px solid var(--teal);
  margin-top: 8px;
  padding-top: 10px;
}

.doc-product-block {
  margin-bottom: 16px;
}

.doc-product-block + .doc-product-block {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.doc-product-continued {
  font-size: 0.75em;
  font-weight: 400;
  color: var(--muted);
  margin-left: 6px;
}

.doc-pricing-product-row td {
  background: var(--background);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 6px 8px 3px !important;
  border-bottom: none !important;
}

/* ─────────────────────────────────────────────────────────────────────────── */

.config-price-orig {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.55;
  text-decoration: line-through;
  line-height: 1.1;
}

.summary-totals-netto {
  border-top: 1.5px solid var(--teal);
  padding-top: 6px;
  margin-top: 2px;
}

.summary-totals-netto > span {
  font-size: 0.78rem;
  color: var(--teal-dark);
  font-weight: 700;
}

.document-notes p:last-child {
  color: #43535f;
  line-height: 1.55;
  white-space: pre-line;
}

/* ── Firme (ultimo blocco del preventivo) ─────────────────── */

.document-firme {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  margin-top: 24px;
  /* Evita che il blocco firme venga spezzato tra due pagine in stampa */
  break-inside: avoid;
  page-break-inside: avoid;
}

.document-firma {
  display: flex;
  flex-direction: column;
}

.document-firma-label {
  color: var(--teal-dark);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 9px;
}

/* Spazio su cui apporre la firma: altezza FISSA e identica nelle due colonne.
   Fissa e non "auto" anche quando ospita l'immagine della firma: così il
   caricamento (asincrono) del PNG non altera l'altezza del blocco dopo che la
   paginazione ha già misurato le pagine. */
.document-firma-spazio {
  height: 46px;
  display: flex;
  align-items: flex-end;
}

.document-firma-img {
  max-height: 100%;
  max-width: 78%;
  object-fit: contain;
  object-position: left bottom;
}

.document-firma-line {
  border-bottom: 1.2px solid var(--line);
}

.document-firma-nome {
  margin: 5px 0 0;
  color: #43535f;
  font-size: 0.82rem;
  font-weight: 600;
}

.document-firma-hint {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.document-totals {
  margin: 0;
}

.document-totals div {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  color: var(--muted);
  font-size: 0.93rem;
}

.document-totals dd {
  margin: 0;
}

.document-totals .document-total {
  margin-top: 10px;
  padding: 16px 0 0;
  border-top: 2px solid var(--teal);
  color: var(--ink);
  font-size: 1.18rem;
  font-weight: 700;
}

.document-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 2px solid var(--teal);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
}

.document-footer--center {
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 3px;
}

.document-footer p {
  margin: 0;
  white-space: pre-line;
}

@media (max-width: 1440px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .summary {
    grid-column: auto;
  }

  .live-preview {
    position: static;
    grid-column: auto;
    grid-row: auto;
    margin-top: 10px;
  }
}

@media (max-width: 600px) {
  .layout {
    padding-top: 28px;
  }

  .customer > .fieldset-body,
  .document-settings > .fieldset-body,
  .services,
  .import-form,
  .edition-selector {
    grid-template-columns: 1fr;
  }

  .logo-row {
    grid-template-columns: 1fr;
  }

  fieldset,
  .summary,
  .product-import {
    padding: 20px;
  }

  .product-card {
    overflow-x: auto;
  }

  .product-modules {
    min-width: 440px;
  }
}

/* ── Cedolini selector in configurator ── */
.cedolini-block {
  margin: 18px 26px 0;
  padding: 14px 18px 16px;
  background: var(--sand);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.cedolini-block-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 13px;
}

.cedolini-block-title {
  font-size: 0.9rem;
  font-weight: 750;
  color: var(--ink);
  white-space: nowrap;
}

.cedolini-block-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.cedolini-tiers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cedolini-tier-btn {
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 7px 20px;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 650;
  cursor: pointer;
  background: var(--paper);
  color: var(--ink);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.cedolini-tier-btn:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.cedolini-tier-btn--active {
  border-color: var(--teal);
  background: var(--teal);
  color: white;
}

.listini-area-row th {
  padding: 9px 14px;
  border-top: 1px solid #f0b69e;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 0.76rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
}

/* ── Topbar navigation ── */
.topbar-nav {
  display: flex;
  gap: 4px;
  align-items: center;
}

.topbar-link {
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}

.topbar-link:hover {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.topbar-link--active {
  color: var(--teal-dark);
  background: var(--teal-soft);
}

/* ── Listini page ── */
.listini-layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 44px clamp(18px, 4vw, 52px) 80px;
}

.listini-page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.listini-page-header h1 {
  margin: 0 0 8px;
  font-size: clamp(1.8rem, 2.8vw, 2.2rem);
  letter-spacing: -0.04em;
}

.listini-page-header > div > p:last-child {
  color: var(--muted);
  margin: 0;
}

.listini-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.listini-save-btn {
  border: 0;
  border-radius: 11px;
  padding: 12px 22px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  color: white;
  background: var(--teal);
  white-space: nowrap;
}

.listini-save-btn:hover {
  background: var(--teal-dark);
}

.listini-save-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.listini-import-details {
  position: relative;
}

.listini-import-summary {
  border: 2px solid var(--teal);
  border-radius: 11px;
  padding: 10px 20px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  color: var(--teal-dark);
  background: var(--paper);
  list-style: none;
  white-space: nowrap;
}

.listini-import-summary::-webkit-details-marker { display: none; }

.listini-import-summary:hover {
  background: var(--teal-soft);
}

.listini-import-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 10;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 20px 24px;
  min-width: 340px;
  max-width: 460px;
}

.listini-import-form {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.listini-import-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
}

/* ── Tier tabs ── */
.tier-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
}

.tier-tab {
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 8px 20px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--paper);
  color: var(--muted);
  transition: border-color 0.13s, color 0.13s, background 0.13s;
}

.tier-tab:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
  background: var(--teal-soft);
}

.tier-tab--active {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.tier-tab--delete {
  margin-left: auto;
  border-color: #f5c0c0;
  color: #a32929;
  background: #fff8f8;
}

.tier-tab--delete:hover {
  background: #fee;
  border-color: #a32929;
}

/* ── Tier detail ── */
.tier-header {
  display: flex;
  align-items: baseline;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.tier-prodotto {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--teal);
  color: #fff;
  padding: 2px 10px;
  border-radius: 999px;
}

/* Tasto "Tabella volumi": compare solo nella testata di PROFIS a Volumi */
.listino-volumi-btn {
  margin-left: auto;
  padding: 7px 16px;
  border: 1px solid var(--teal);
  border-radius: 999px;
  background: #fff;
  color: var(--teal-dark);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.listino-volumi-btn:hover { background: var(--teal); color: #fff; }

/* Finestra della tabella volumi */
.volumi-overlay {
  position: fixed;
  inset: 0;
  background: rgba(23, 37, 49, 0.35);
  z-index: 200;
}

.volumi-modale {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(900px, calc(100vw - 40px));
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
  z-index: 201;
}

.volumi-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--line);
}

.volumi-head h2 { margin: 0; font-size: 1.15rem; }
.volumi-sottotitolo { margin: 6px 0 0; font-size: 0.85rem; color: var(--muted); }
.volumi-head-azioni { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.volumi-head .ass-drawer-close { font-size: 1.5rem; line-height: 1; padding: 0 8px; }
.volumi-head .listino-volumi-btn { margin-left: 0; padding: 5px 14px; font-size: 0.8rem; }
.volumi-body { padding: 20px 24px 24px; overflow: auto; }

.volumi-input {
  width: 90px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 0.85rem;
  text-align: right;
}

.volumi-input:focus { outline: 2px solid var(--teal); outline-offset: -1px; border-color: var(--teal); }
.volumi-tabella tfoot td { font-weight: 700; background: var(--background); }
.volumi-riga-totale td { font-size: 0.95rem; color: var(--teal-dark); }
.volumi-riga-documenti td { font-weight: 700; }

.volumi-esito {
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px solid var(--teal);
  border-radius: 12px;
  background: var(--teal-soft);
}

.volumi-esito--oltre { border-color: #d99a2b; background: #fdf6e7; }

.volumi-esito-label {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.volumi-esito-classe { margin: 6px 0 0; font-size: 1.05rem; font-weight: 700; color: var(--ink); }

.volumi-esito-codice {
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fff;
  font-size: 0.78rem;
  color: var(--teal-dark);
}

.volumi-esito-nota { margin: 8px 0 0; font-size: 0.85rem; color: var(--muted); }

.volumi-prezzi {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin: 12px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid rgba(23, 37, 49, 0.12);
}

.volumi-prezzi div { display: flex; flex-direction: column; gap: 2px; }
.volumi-prezzi dt { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.volumi-prezzi dd { margin: 0; font-size: 1rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.volumi-prezzi-totale dd { color: var(--teal-dark); font-size: 1.15rem; }

.volumi-start {
  margin-top: 12px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: 12px;
  background: #fff;
}

.volumi-start--assente { border-left-color: var(--line); }

.volumi-start-rif {
  display: inline-block;
  margin: 2px 4px 2px 0;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 0.76rem;
  font-weight: 700;
}

.volumi-esito-attesa {
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.tier-ref {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.tier-date {
  font-size: 0.82rem;
  color: var(--muted);
}

.listini-sections {
  display: grid;
  gap: 28px;
}

.listini-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 750;
}

.listini-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 0.75rem;
  font-weight: 700;
}

.listini-empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--muted);
  background: var(--paper);
  border: 1px dashed var(--line);
  border-radius: 16px;
}

.listini-empty p {
  margin: 6px 0;
}

.listini-empty strong {
  color: var(--teal-dark);
}

/* ── Listini tables ── */
.listini-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
}

.listini-no-data {
  padding: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.listini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.listini-table thead {
  background: #faf5f2;
  color: #5b4b43;
}

.listini-table th,
.listini-table td {
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.listini-table thead th {
  border-top: none;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.listini-table .code-cell {
  font-family: "SF Mono", "Fira Mono", monospace;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.listini-table .price-col {
  text-align: right;
  width: 140px;
  white-space: nowrap;
}

.listini-table--auto .fit-col {
  width: 1%;
  white-space: nowrap;
}

.conf-type-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.conf-type-badge--base {
  background: #e8f4fd;
  color: #1a5f8a;
}

.conf-type-badge--estesa {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.conf-type-badge--other {
  background: #f1eefc;
  color: #5b3fa0;
}

.config-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.config-split-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.config-split-group--other {
  margin-top: 0;
}

.config-split-title {
  margin: 0;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.config-split-title--base {
  background: #e8f4fd;
  color: #1a5f8a;
}

.config-split-title--estesa {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.config-split-title--other {
  background: #f1eefc;
  color: #5b3fa0;
}

@media (max-width: 860px) {
  .config-split {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    size: A4;
    margin: 0;
  }

  body {
    background: white;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  body > .topbar,
  .builder,
  .summary,
  .preview-toolbar,
  .draft-feedback {
    display: none !important;
  }

  .layout {
    display: block;
    padding: 0;
    max-width: none;
  }

  .live-preview {
    position: static;
    display: block;
    padding: 0;
    margin: 0;
  }

  /* Ogni foglio è una pagina A4 esatta */
  .a4-sheet,
  .a4-sheet-extra {
    width: 210mm !important;
    height: 297mm !important;
    padding: 22mm 22mm 18mm !important;
    margin: 0 !important;
    box-shadow: none;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    break-inside: avoid;
    break-after: page;
    page-break-after: always;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  /* Ultimo foglio: nessun break extra (evita pagina bianca finale) */
  .a4-sheet:last-child,
  .a4-sheet-extra:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  /* In stampa la tabella diventa reale: thead si ripete su ogni pagina.
     Usiamo > su ogni livello per non toccare le tabelle annidate. */
  .a4-print-table {
    display: table;
    width: 100%;
    flex-grow: 1;
    min-height: var(--a4-table-min-h, auto); /* calcolata in JS, assicura footer sempre a fondo pagina */
  }

  .a4-print-head {
    display: table-header-group;
  }

  .a4-print-body {
    display: table-row-group;
  }

  .a4-print-head > tr,
  .a4-print-body > tr {
    display: table-row;
  }

  .a4-print-head > tr > td,
  .a4-print-body > tr > td {
    display: table-cell;
    padding: 0;
    overflow: visible; /* resetta overflow:hidden ereditato dal CSS schermo — evita il taglio della J */
  }

  /* Piccolo spazio tra header e contenuto */
  .a4-print-body-cell {
    padding-top: 14px;
  }

  /* Footer in posizione normale: il flex della sheet lo spinge in fondo */
  .document-footer {
    position: static;
    margin-top: auto;
  }

  .a4-sheet * {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}

/* ── Login ────────────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--background);
}

.login-wrap {
  width: 100%;
  max-width: 420px;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.login-card {
  width: 100%;
  background: var(--paper);
  border-radius: 22px;
  box-shadow: 0 24px 56px rgba(20, 39, 46, 0.11);
  padding: 44px 40px 40px;
  text-align: center;
}

.login-logo {
  margin-bottom: 28px;
}

.login-logo img {
  max-width: 170px;
  height: auto;
  display: block;
  margin: 0 auto;
}

.login-title {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 6px;
}

.login-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 30px;
}

.login-form {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.01em;
}

.login-input {
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--background);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.login-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-soft);
}

.login-error {
  color: #c0392b;
  font-size: 0.88rem;
  min-height: 1.3em;
  margin: 0;
  text-align: center;
  font-weight: 500;
}

.login-button {
  margin-top: 6px;
  padding: 14px;
  background: var(--teal);
  color: white;
  border: none;
  border-radius: 10px;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  letter-spacing: 0.02em;
}

.login-button:hover:not(:disabled) {
  background: var(--teal-dark);
}

.login-button:active:not(:disabled) {
  transform: translateY(1px);
}

.login-button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.login-brand {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0;
  letter-spacing: 0.02em;
}

/* Logout button in topbar */
.topbar-logout {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font: inherit;
  color: var(--muted);
  font-size: 0.88rem;
  margin-left: 8px;
  transition: color 0.15s;
}

.topbar-logout:hover {
  color: var(--teal-dark);
}

/* ── Servizi ──────────────────────────────────────────────── */

.servizi-header-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 600px) {
  .servizi-header-fields {
    grid-template-columns: 1fr;
  }
}

.servizi-title-label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0;
}

.servizi-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 10px;
}

.servizi-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.servizi-amount-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.servizi-field-label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
}

.servizi-price-input {
  width: 120px;
  flex-shrink: 0;
  padding: 9px 10px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 0.88rem;
  color: var(--ink);
  background: var(--background);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  text-align: right;
}

.servizi-price-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-soft);
}

.servizi-price-input:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.servizi-omaggio-flag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.cc-inline-flag {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--muted);
  cursor: pointer;
}

.cc-inline-flag input[type="checkbox"] {
  width: 15px;
  height: 15px;
  padding: 0;
  accent-color: var(--teal);
  cursor: pointer;
  flex-shrink: 0;
}

.cc-field-hint {
  font-size: 0.74rem;
  font-weight: 400;
  color: var(--muted);
}

.cc-contributo-spese-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.cc-contributo-spese-row span {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
}

.servizi-omaggio-flag input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--teal);
  cursor: pointer;
  flex-shrink: 0;
}

.servizi-row.is-omaggio .servizi-omaggio-flag {
  color: var(--teal-dark);
}

.doc-service-omaggio {
  font-style: italic;
  color: var(--teal-dark);
  font-weight: 600;
}

.servizi-input {
  flex: 1;
  padding: 9px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--background);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.servizi-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-soft);
}

.servizi-remove {
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1.05rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
  line-height: 1;
}

.servizi-remove:hover {
  color: #c0392b;
  background: #fde8e8;
}

.servizi-add {
  width: 100%;
  padding: 9px;
  background: none;
  border: 1.5px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  margin-bottom: 18px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.servizi-add:hover {
  color: var(--teal);
  border-color: var(--teal);
  background: var(--teal-soft);
}

.extra-groups-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 12px;
}

.extra-group-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fafbfc;
}

.extra-group-box .servizi-add {
  margin-bottom: 0;
}

.extra-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.servizi-templates {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.servizi-template-select {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 0.88rem;
  background: var(--background);
  color: var(--ink);
  cursor: pointer;
  outline: none;
}

.servizi-template-select:focus {
  border-color: var(--teal);
}

.servizi-save-btn {
  padding: 8px 14px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  border: none;
  border-radius: 8px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.servizi-save-btn:hover {
  background: var(--teal);
  color: white;
}

.servizi-template-form {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.servizi-template-form .login-input {
  flex: 1;
  min-width: 140px;
  padding: 8px 12px;
  font-size: 0.9rem;
}

.servizi-confirm-btn {
  padding: 8px 16px !important;
  font-size: 0.9rem !important;
  width: auto !important;
}

.servizi-cancel-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s;
}

.servizi-cancel-btn:hover {
  color: var(--ink);
}

/* Servizi nel documento A4 */
.document-services {
  margin-bottom: 18px;
}

.document-services-list {
  list-style: none;
  padding: 0;
  margin: 5px 0 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.document-services-list li {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--ink);
}

.document-services-list li {
  justify-content: space-between;
}

.document-services-list li::before {
  content: "•";
  color: var(--teal);
  font-weight: 700;
  flex-shrink: 0;
}

.doc-service-desc {
  flex: 1;
}

.doc-service-price {
  margin-left: auto;
  padding-left: 12px;
  font-weight: 650;
  color: var(--teal-dark);
  white-space: nowrap;
  font-size: 0.85rem;
}

.doc-service-global-price {
  margin: 8px 0 0;
  padding: 5px 10px;
  border-top: 1.5px solid var(--teal);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--teal-dark);
}

/* ── Sconto ───────────────────────────────────────────────── */

.sconto-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 14px;
  line-height: 1.5;
}

.sconto-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.sconto-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
}

.sconto-row-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  min-width: 58px;
}

.sconto-fields {
  display: flex;
  gap: 10px;
  flex: 1;
}

.sconto-field {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.sconto-field-lbl {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.sconto-pct-input {
  width: 60px;
  padding: 5px 7px;
  border: 1.5px solid var(--line);
  border-radius: 7px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  text-align: right;
  background: #fff;
  color: var(--ink);
}

.sconto-pct-input:focus {
  outline: none;
  border-color: var(--teal);
}

.sconto-pct-symbol {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
}

.sconto-remove {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: #b0b8c1;
  font-size: 0.85rem;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
}

.sconto-remove:hover {
  background: #fee2e2;
  color: #b91c1c;
}

.sconto-add {
  width: 100%;
  padding: 9px;
  background: none;
  border: 1.5px dashed var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}

.sconto-add:hover {
  color: var(--teal);
  border-color: var(--teal);
  background: var(--teal-soft);
}

.sconto-progressivo-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
}

.sconto-progressivo-toggle input[type="checkbox"] {
  width: 15px;
  height: 15px;
  padding: 0;
  accent-color: var(--teal);
  cursor: pointer;
  flex-shrink: 0;
}

.sconto-esclusioni-wrap {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.quota-accessoria-wrap {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.quota-accessoria-input {
  width: 84px;
  padding: 5px 7px;
  border: 1.5px solid var(--line);
  border-radius: 7px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  text-align: right;
  background: #fff;
  color: var(--ink);
}

.quota-accessoria-input:focus {
  outline: none;
  border-color: var(--teal);
}

.sconto-esclusioni {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sconto-escl-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--ink);
  cursor: pointer;
}

.sconto-escl-name {
  flex: 1;
}

/* ── Condizioni commerciali (configuratore) ──────────────── */

.condizioni-group {
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--sand);
}

.condizioni-group-title {
  margin: 0 0 12px;
  font-size: 0.82rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--teal-dark);
}

.condizioni-group-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.condizioni-standalone {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 600px) {
  .condizioni-group-fields,
  .condizioni-standalone {
    grid-template-columns: 1fr;
  }
}

.cc-select-row {
  display: flex;
  gap: 8px;
}

.cc-select-row .cc-select {
  flex: 1;
  min-width: 0;
}

.cc-add-btn {
  flex: 0 0 auto;
  width: 40px;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  background: none;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}

.cc-add-btn:hover {
  color: var(--teal);
  border-color: var(--teal);
  background: var(--teal-soft);
}

/* ── Condizioni commerciali (documento A4) ───────────────── */

.document-condizioni {
  margin-top: 32px;
  margin-bottom: 14px;
}

.document-condizioni-content {
  margin-top: 6px;
}

.doc-condizioni-body {
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  font-size: 0.68rem;
  line-height: 1.35;
}

.doc-condizioni-groups {
  display: flex;
  flex-direction: column;
}

.doc-condizioni-group {
  border-right: none;
  border-bottom: 1px solid var(--line);
}

.doc-condizioni-group:last-child {
  border-bottom: none;
}

.doc-condizioni-group-hd {
  padding: 3px 8px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 0.62rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid var(--line);
}

.doc-condizioni-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  padding: 2px 8px;
  border-bottom: 1px solid var(--line);
}

.doc-condizioni-row:last-child {
  border-bottom: none;
}

.doc-condizioni-lbl {
  color: var(--muted);
  flex-shrink: 0;
}

.doc-condizioni-val {
  color: var(--ink);
  font-weight: 600;
  text-align: right;
}

.doc-condizioni-standalone {
  display: flex;
  border-top: 1px solid var(--line);
}

.doc-condizioni-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 3px 8px;
  border-right: 1px solid var(--line);
}

.doc-condizioni-cell:last-child {
  border-right: none;
}

.doc-condizioni-cell-lbl {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.doc-condizioni-cell-val {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--ink);
}

.feedback--ok {
  color: #1a7a4a;
}

.feedback--error {
  color: #b91c1c;
}

/* ─── Ricerca intelligente listini ──────────────────────────────────────── */

.listini-search-wrap {
  position: relative;
  margin-bottom: 20px;
}

.listini-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}

.listini-search {
  width: 100%;
  padding: 10px 14px 10px 36px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 0.9rem;
  background: var(--paper);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.listini-search:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-soft);
}

.listini-search::-webkit-search-cancel-button { cursor: pointer; }

.listini-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: 380px;
  overflow-y: auto;
  z-index: 200;
  padding: 6px 0;
}

.listini-search-result {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 16px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}

.listini-search-result:hover {
  background: var(--background);
}

.lsr-badges {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  flex-shrink: 0;
}

.lsr-prodotto {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--teal);
  color: white;
  padding: 2px 8px;
  border-radius: 999px;
}

.lsr-unit {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 1px 7px;
  border-radius: 999px;
  text-transform: lowercase;
}

.lsr-unit--cedolini {
  background: #e3f2fd;
  color: #1565c0;
}

.lsr-unit--pdl {
  background: #f3e5f5;
  color: #6a1b9a;
}

.lsr-unit--documenti {
  background: #e8f5e9;
  color: #2e7d32;
}

.lsr-tipo {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 1px 7px;
  border-radius: 999px;
  background: #fff3e0;
  color: #e65100;
  white-space: nowrap;
}

.lsr-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.lsr-tier {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink);
}

.lsr-classe {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lsr-identity {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  margin-top: 2px;
}

.lsr-codice {
  font-size: 0.72rem;
  font-weight: 600;
  font-family: "SF Mono", "Consolas", monospace;
  color: var(--muted);
  flex-shrink: 0;
}

.lsr-nome {
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lsr-prices {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-end;
  flex-shrink: 0;
}

.lsr-price-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.lsr-price-lbl {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  min-width: 22px;
}

.lsr-price-val {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.lsr-price-canone {
  color: var(--teal-dark);
}

.listini-search-result mark {
  background: #fff3cd;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.listini-search-empty {
  padding: 16px 20px;
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0;
}

.listini-search-more {
  padding: 10px 16px;
  font-size: 0.78rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  margin: 4px 0 0;
}

/* ─── Tipo listino toggle (listini page) ─────────────────────────────────── */

.product-filter {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.listino-tipo-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
}

.listino-tipo-btn {
  padding: 7px 18px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.listino-tipo-btn:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.listino-tipo-btn--active {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
}

.listino-tipo-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  letter-spacing: 0.03em;
}

.listino-tipo-badge--lc {
  background: #e8f5e9;
  color: #2e7d32;
}

.listino-tipo-badge--sc {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

/* ─── Tipo listino selector (configuratore) ──────────────────────────────── */

.tipo-listino-block {
  background: var(--background);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 12px;
}

.tipo-listino-header {
  margin-bottom: 10px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.tipo-listino-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tipo-listino-option {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  transition: border-color 0.12s, background 0.12s;
}

.tipo-listino-option input[type="radio"] {
  accent-color: var(--teal);
}

.tipo-listino-option--active {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.tipo-listino-option--disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

/* ═══════════════════════════════════════════════════════════════════════════
   DASHBOARD
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Layout ── */
.dash-layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 52px clamp(18px, 4vw, 52px) 100px;
  display: flex;
  flex-direction: column;
  gap: 48px;
}

/* ── Greeting ── */
.dash-greeting {
  padding-bottom: 4px;
}

.dash-greeting h1 {
  margin: 4px 0 6px;
  font-size: clamp(2rem, 3.5vw, 2.8rem);
  letter-spacing: -0.04em;
  font-weight: 800;
}

.dash-date {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
  text-transform: capitalize;
}

/* ── Quick-access cards ── */
.dash-shortcuts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 680px) {
  .dash-shortcuts { grid-template-columns: 1fr; }
}

.dash-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 20px 22px 22px;
  border-radius: 16px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
  cursor: pointer;
}

.dash-card:hover {
  border-color: var(--teal);
  box-shadow: 0 6px 24px rgba(226, 92, 37, 0.10);
  transform: translateY(-2px);
}

.dash-card-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--teal-soft);
  color: var(--teal);
}

.dash-card-icon svg {
  width: 22px;
  height: 22px;
}

.dash-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.dash-card-body strong {
  font-size: 1rem;
  font-weight: 700;
}

.dash-card-body span {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.3;
}

.dash-card-arrow {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--muted);
  transition: color 0.15s, transform 0.15s;
}

.dash-card:hover .dash-card-arrow {
  color: var(--teal);
  transform: translateX(2px);
}

/* ── Events section ── */
.dash-cli-alert {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-radius: 14px;
  background: #fffaf0;
  border: 1.5px solid #fbd38d;
}

.dash-cli-alert-icon {
  flex-shrink: 0;
  color: #c05621;
  display: grid;
  place-items: center;
}

.dash-cli-alert-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dash-cli-alert-body strong {
  font-size: 0.92rem;
  color: #7b341e;
}

.dash-cli-alert-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dash-cli-chip {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: #fff;
  color: #c05621;
  border: 1px solid #fbd38d;
  text-decoration: none;
}

.dash-cli-chip:hover { background: #fef0dc; }
.dash-cli-chip--more { color: #9c4221; cursor: default; }
.dash-cli-chip--more:hover { background: #fff; }

.dash-cli-alert-cta { flex-shrink: 0; }

.dash-eventi-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.dash-eventi-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.dash-eventi-header h2 {
  margin: 0 0 4px;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.dash-eventi-header p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.dash-eventi-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Single event row ── */
.dash-evento {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  transition: border-color 0.15s;
}

.dash-evento.ev-overdue { border-left: 4px solid #e53e3e; }
.dash-evento.ev-urgent  { border-left: 4px solid #dd6b20; }
.dash-evento.ev-soon    { border-left: 4px solid #d69e2e; }
.dash-evento.ev-ok      { border-left: 4px solid #38a169; }
.dash-evento.ev-done    { border-left: 4px solid #a0aec0; opacity: 0.6; }

/* Dot indicator */
.dash-evento-dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #a0aec0;
}
.ev-overdue .dash-evento-dot { background: #e53e3e; }
.ev-urgent  .dash-evento-dot { background: #dd6b20; }
.ev-soon    .dash-evento-dot { background: #d69e2e; }
.ev-ok      .dash-evento-dot { background: #38a169; }

/* Checkbox */
.dash-evento-check {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.dash-evento-check input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.dash-evento-checkmark {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
  transition: background 0.15s, border-color 0.15s;
  background: var(--paper);
}

.dash-evento-check input:checked + .dash-evento-checkmark {
  background: var(--teal);
  border-color: var(--teal);
}

.dash-evento-check input:checked + .dash-evento-checkmark::after {
  content: "";
  display: block;
  width: 5px;
  height: 9px;
  border: 2px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
}

/* Content */
.dash-evento-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dash-evento-top {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.dash-evento-title {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

.ev-done .dash-evento-title {
  text-decoration: line-through;
  color: var(--muted);
}

.dash-evento-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  background: #edf2f7;
  color: #4a5568;
}
.ev-overdue .dash-evento-badge { background: #fff5f5; color: #c53030; }
.ev-urgent  .dash-evento-badge { background: #fffaf0; color: #c05621; }
.ev-soon    .dash-evento-badge { background: #fffff0; color: #975a16; }
.ev-ok      .dash-evento-badge { background: #f0fff4; color: #276749; }

.dash-evento-desc {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.dash-evento-date {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}

/* Action buttons */
.dash-evento-actions {
  flex-shrink: 0;
  display: flex;
  gap: 4px;
}

.ev-edit-btn,
.ev-delete-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.12s, color 0.12s;
}

.ev-edit-btn:hover { background: var(--teal-soft); color: var(--teal); }
.ev-delete-btn:hover { background: #fff5f5; color: #c53030; }

/* Empty state */
.dash-eventi-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 52px 24px;
  border-radius: 12px;
  border: 2px dashed var(--line);
  color: var(--muted);
  text-align: center;
}

.dash-eventi-empty svg { opacity: 0.35; }
.dash-eventi-empty p { margin: 0; font-size: 0.92rem; }

/* ── Modal ── */
.dash-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(23, 37, 49, 0.45);
  display: grid;
  place-items: center;
  z-index: 200;
  padding: 24px;
  backdrop-filter: blur(2px);
}

.dash-modal {
  background: var(--paper);
  border-radius: 20px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 24px 64px rgba(20, 39, 46, 0.18);
  overflow: hidden;
}

.dash-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
}

.dash-modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.dash-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.12s;
}

.dash-modal-close:hover { background: var(--background); }

.dash-modal-body {
  padding: 22px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dash-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dash-field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

.dash-field label span {
  color: var(--teal);
}

.dash-field-row {
  display: flex;
  gap: 14px;
}

.dash-field-row .dash-field {
  flex: 1;
  min-width: 0;
}

.dash-field input[type="text"],
.dash-field input[type="date"],
.dash-field input[type="email"],
.dash-field input[type="file"],
.dash-field textarea {
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--paper);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  resize: vertical;
}

.dash-field input:focus,
.dash-field textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-soft);
}

.cli-import-check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}

.cli-import-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
  cursor: pointer;
}

.dash-field-error {
  padding: 10px 14px;
  border-radius: 8px;
  background: #fff5f5;
  color: #c53030;
  font-size: 0.85rem;
  border: 1px solid #fed7d7;
}

.dash-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

/* ── Generic buttons (shared with other pages if not already defined) ── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: 999px;
  border: none;
  background: var(--teal);
  color: white;
  font-weight: 700;
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn-primary:hover { background: var(--teal-dark); }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  padding: 9px 20px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-secondary:hover { background: var(--background); border-color: #b0bec5; }

/* ── Configuratore: selezione cliente esistente ──────────────────────────── */
.customer-picker {
  grid-column: 1 / -1;
  position: relative;
}

.customer-picker-btn svg { flex-shrink: 0; margin-right: 6px; }

.customer-picker-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  width: min(420px, 100%);
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(20, 39, 46, 0.14);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.customer-picker-search {
  padding: 9px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
}

.customer-picker-search:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-soft);
}

.customer-picker-results {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.customer-picker-result {
  display: flex;
  flex-direction: column;
  gap: 1px;
  text-align: left;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}

.customer-picker-result:hover { background: var(--background); }
.customer-picker-result strong { font-size: 0.88rem; color: var(--ink); }
.customer-picker-result span { font-size: 0.76rem; color: var(--muted); }

.customer-picker-empty {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 8px 10px;
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════
   Assegnazione Preventivi
   ═══════════════════════════════════════════════════════ */

/* ── Pagina full-height ───────────────────────────────────── */
.ass-page { overflow: hidden; height: 100vh; }

.ass-layout {
  height: calc(100vh - 72px);
  display: flex;
  flex-direction: column;
  padding: 1.2rem 2rem 0;
  overflow: hidden;
}

.ass-header {
  flex-shrink: 0;
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
}
.ass-header h1 { font-size: 1.3rem; margin: 0; }
.ass-header .eyebrow { margin: 0; }
.ass-header .feedback { margin: 0; font-size: 0.82rem; }

/* ── Tabella ──────────────────────────────────────────────── */
.ass-table-wrapper {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  margin-bottom: 0;
}

.ass-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.ass-table thead {
  background: var(--background);
  position: sticky;
  top: 0;
  z-index: 1;
}

.ass-table th {
  padding: 8px 12px;
  text-align: left;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #607d8b;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.ass-table td {
  padding: 7px 12px;
  border-bottom: 1px solid #f0f4f7;
  vertical-align: middle;
  color: var(--ink);
  white-space: nowrap;
}

.ass-table tbody tr:last-child td { border-bottom: none; }
.ass-table tbody tr.ass-row:hover  { background: #f8fbfd; }

.ass-num-cell    { font-weight: 700; color: var(--teal); }
.ass-cliente-cell{ max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.ass-muted       { color: #607d8b; }

.ass-prodotto {
  display: inline-block;
  background: var(--background);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--ink);
}

.ass-prodotto-dettaglio {
  margin-top: 4px;
  font-size: 0.72rem;
  color: #607d8b;
  max-width: 260px;
}

.ass-empty   { text-align: center; padding: 3rem; color: #90a4ae; white-space: normal; }
.ass-missing { color: #b0bec5; }

.ass-prov-cell {
  color: #607d8b;
  min-width: 100px;
  max-width: 160px;
  cursor: text;
  border-radius: 4px;
  outline: none;
  overflow: hidden;
  white-space: nowrap;
}
.ass-prov-cell:hover { background: #f0f4f7; }
.ass-prov-cell:focus {
  background: #f0f7ff;
  outline: 2px solid var(--teal);
  outline-offset: -1px;
  white-space: normal;
  overflow: visible;
}
.ass-prov-cell:empty::before {
  content: "—";
  color: #b0bec5;
  pointer-events: none;
}
.ass-prov-cell:focus:empty::before { content: ""; }

.ass-stato-data {
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 3px 4px;
  font-size: 0.78rem;
  font-family: inherit;
  color: #607d8b;
  background: transparent;
  outline: none;
  max-width: 130px;
}
.ass-stato-data:hover  { background: #f0f4f7; border-color: var(--line); }
.ass-stato-data:focus  { background: #f0f7ff; border-color: var(--teal); }
.ass-stato-data:disabled {
  color: #cfd8dc;
  cursor: not-allowed;
  background: transparent;
}

/* ── Pulsante ⋮ ───────────────────────────────────────────── */
.ass-actions { text-align: right; }

.ass-menu-btn {
  background: none;
  border: 1.5px solid var(--line);
  cursor: pointer;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--ink);
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.ass-menu-btn:hover { background: var(--background); border-color: #b0bec5; }

/* ── Stato badge ──────────────────────────────────────────── */
.ass-stato {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.ass-stato--wip  { background: #fff8e1; color: #f57f17; border: 1px solid #ffe082; }
.ass-stato--ok   { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.ass-stato--no   { background: #fce4e4; color: #c62828; border: 1px solid #ef9a9a; }
.ass-stato--sent { background: #e3f2fd; color: #1565c0; border: 1px solid #90caf9; }
.ass-stato--done { background: #ede7f6; color: #4527a0; border: 1px solid #b39ddb; }

.ass-stato-btn {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  letter-spacing: inherit;
}
.ass-stato-btn:hover { filter: brightness(0.93); }

/* ── Stato dropdown ───────────────────────────────────────── */
.stato-dropdown {
  position: absolute;
  z-index: 500;
  background: #fff;
  border: 1px solid #dde3ea;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.13);
  padding: 4px;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stato-dropdown-opt {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 12px;
  border-radius: 5px;
  border: none;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: transparent;
  transition: filter 0.1s;
}
.stato-dropdown-opt:hover { filter: brightness(0.88); }

/* ── Drawer overlay ───────────────────────────────────────── */
.ass-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(23,37,49,0.35);
  z-index: 200;
}

/* ── Drawer laterale ──────────────────────────────────────── */
.ass-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 300px;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -6px 0 32px rgba(0,0,0,0.14);
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s cubic-bezier(.4,0,.2,1);
}
.ass-drawer--open { transform: translateX(0); }

.ass-drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 1.2rem 1.2rem 1rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

/* ── Clienti potenziali ─────────────────────────────────────────────────── */
.cli-sezioni { display: flex; gap: 8px; margin: 4px 0 18px; flex-wrap: wrap; }

/* Le due sezioni a schede si frappongono fra .ass-layout (che ha l'altezza
   della finestra) e il riquadro della tabella. Se restano blocchi normali la
   catena flex si interrompe: il riquadro non riceve più un'altezza massima,
   cresce fino a contenere tutte le righe e la rubrica non scorre più.
   Il display:flex non riapre la sezione nascosta perché [hidden] è !important. */
#cli-sezione-clienti,
#cli-sezione-potenziali {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.cli-potenziali-barra {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.cli-potenziali-nota { margin: 0; max-width: 78ch; font-size: 0.85rem; color: var(--muted); }
.cli-sub { display: block; margin-top: 2px; font-size: 0.74rem; font-weight: 500; color: var(--muted); }

/* ── Schede cliente e potenziale ────────────────────────────────────────────
   Pannello ampio: i dati devono leggersi tutti senza scorrere in una colonna
   stretta. */
.ass-drawer--scheda { width: min(920px, 100vw); }
.ass-drawer--scheda .ass-drawer-head { padding: 26px 30px 20px; align-items: flex-start; }
.ass-drawer--scheda .ass-drawer-body { padding: 0 30px 30px; }

.scheda-eyebrow {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--teal);
}

.scheda-titolo { margin: 6px 0 0; font-size: 1.5rem; line-height: 1.2; color: var(--ink); }
.scheda-sottotitolo { margin: 6px 0 0; font-size: 0.9rem; color: var(--muted); }
.scheda-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.scheda-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--background);
  border: 1px solid var(--line);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.scheda-badge-label {
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.scheda-sezione { padding: 22px 0; border-top: 1px solid var(--line); }
.scheda-sezione:first-of-type { border-top: none; }

.scheda-sezione-titolo {
  margin: 0 0 14px;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.scheda-griglia {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px 22px;
}

.scheda-campo {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}

.scheda-campo-label {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.scheda-campo-valore { font-size: 0.95rem; font-weight: 600; color: var(--ink); word-break: break-word; }
.scheda-campo-valore a { color: var(--teal-dark); text-decoration: none; }
.scheda-campo-valore a:hover { text-decoration: underline; }
.scheda-vuoto-campo { font-weight: 500; color: #9aa7b1; font-style: italic; }

.scheda-tabella-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.scheda-tabella { font-size: 0.85rem; margin: 0; }
.scheda-vuoto { margin: 0; padding: 18px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); font-size: 0.88rem; text-align: center; }

.scheda-azioni {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.scheda-azioni .tier-tab--delete { margin-left: auto; }

/* I campi editabili del potenziale seguono la stessa griglia */
/* Stessa forma dei campi in sola lettura, ma con l'input dentro */
.scheda-griglia .pot-campo {
  margin-bottom: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  font-size: 0.68rem;
  letter-spacing: 0.07em;
}

.scheda-griglia .pot-campo input { border: none; padding: 0; font-size: 0.95rem; font-weight: 600; }
.scheda-griglia .pot-campo input:focus { outline: none; border: none; box-shadow: none; }
.scheda-griglia .pot-campo:focus-within { border-color: var(--teal); box-shadow: 0 0 0 2px var(--teal-soft); }

.pot-campo--largo { margin-top: 16px; }

@media (max-width: 700px) {
  .ass-drawer--scheda .ass-drawer-head { padding: 20px 18px 16px; }
  .ass-drawer--scheda .ass-drawer-body { padding: 0 18px 24px; }
  .scheda-titolo { font-size: 1.25rem; }
}

.pot-campo {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.pot-campo input,
.pot-campo textarea {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 0.88rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  resize: vertical;
}

.pot-campo input:focus,
.pot-campo textarea:focus { outline: 2px solid var(--teal); outline-offset: -1px; border-color: var(--teal); }

/* Avviso "dati da compilare" sul potenziale */
.pot-avviso {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid #f0c48a;
  border-left: 4px solid #d99a2b;
  border-radius: 10px;
  background: #fdf6e7;
}

.pot-avviso--completo { border-color: var(--teal); border-left-color: var(--teal); background: var(--teal-soft); }
.pot-avviso-titolo { margin: 0; font-size: 0.88rem; color: var(--ink); }
.pot-avviso-mancanti { margin: 8px 0 0; font-size: 0.8rem; color: var(--muted); }
.pot-avviso-ok { margin: 8px 0 0; font-size: 0.8rem; color: var(--teal-dark); }

.pot-avviso-campo {
  display: inline-block;
  margin: 2px 3px 2px 0;
  padding: 2px 9px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #f0c48a;
  font-size: 0.74rem;
  font-weight: 700;
  color: #b26a00;
}

.pot-avviso-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--teal-dark);
  text-decoration: none;
}

.pot-avviso-link:hover { text-decoration: underline; }

.pot-incompleto {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #fff4e5;
  color: #b26a00;
  font-size: 0.7rem;
  font-weight: 700;
}

/* Colonna "Tipo cliente": già in rubrica oppure nome nuovo */
.ass-tipo {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.ass-tipo--cliente { background: #e8f5e9; color: #2e7d32; }
.ass-tipo--nuovo   { background: #fff4e5; color: #b26a00; }

.ass-drawer-info { flex: 1; min-width: 0; }
.ass-drawer-num  { font-size: 1rem; font-weight: 700; color: var(--teal); }
.ass-drawer-sub  { font-size: 0.82rem; color: var(--ink); margin-top: 3px; }
.ass-drawer-date { font-size: 0.78rem; color: #607d8b; margin-top: 2px; }

.ass-drawer-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  color: #607d8b;
  flex-shrink: 0;
  transition: background 0.15s;
}
.ass-drawer-close:hover { background: var(--background); }

.ass-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0;
}

.ass-drawer-section {
  padding: 0.5rem 0;
  border-bottom: 1px solid #f0f4f7;
}
.ass-drawer-section:last-child { border-bottom: none; }
.ass-drawer-section--danger { margin-top: auto; }

.ass-drawer-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #90a4ae;
  padding: 0 1.2rem;
  margin: 0 0 4px;
}

.ass-drawer-action {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 1.2rem;
  background: none;
  border: none;
  text-align: left;
  font-size: 0.86rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.12s;
}
.ass-drawer-action svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.65; }
.ass-drawer-action:hover { background: #f4f7f5; }
.ass-drawer-action--danger        { color: #c62828; }
.ass-drawer-action--danger:hover  { background: #fce4e4; }
.ass-drawer-action--active-ok     { color: #2e7d32; background: #e8f5e9; }
.ass-drawer-action--active-ok:hover { background: #c8e6c9; }
.ass-drawer-action--active-no     { color: #c62828; background: #fce4e4; }
.ass-drawer-action--active-no:hover { background: #ffcdd2; }
.ass-drawer-action--active-sent   { color: #1565c0; background: #e3f2fd; }
.ass-drawer-action--active-sent:hover { background: #bbdefb; }
.ass-drawer-action--active-done   { color: #4527a0; background: #ede7f6; }
.ass-drawer-action--active-done:hover { background: #d1c4e9; }

/* Dashboard card accent */
.dash-card--assegnazioni { --card-accent: #5c6bc0; }

/* ── Clienti: contatti e preventivi collegati (drawer) ───────────────────── */
.cli-contatti {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--ink);
}

/* Etichetta e valore su due colonne: gli indirizzi email lunghi vanno a capo
   dentro la loro colonna invece di sfasare la riga. */
.cli-contatti > div {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  /* ereditato anche dal testo del valore, che non è dentro un elemento suo */
  overflow-wrap: anywhere;
}

.cli-contatti strong {
  font-weight: 600;
  color: var(--muted);
}

.cli-prev-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cli-prev-row {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--background);
}

.cli-prev-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.cli-prev-num {
  font-weight: 700;
  font-size: 0.88rem;
}

.cli-prev-prodotto {
  font-size: 0.82rem;
  color: var(--ink);
}

.cli-prev-date {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

.cli-prev-empty {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}

/* ── Modal codici ─────────────────────────────────────────── */
.codici-overlay {
  position: fixed;
  inset: 0;
  background: rgba(23,37,49,0.45);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.codici-modal {
  background: #fff;
  border-radius: 14px;
  width: min(480px, 96vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  overflow: hidden;
}

.codici-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.3rem 0.8rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.codici-modal-head h3 { margin: 0; font-size: 1rem; font-weight: 700; }

.codici-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.6rem 1rem 0;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.codici-tab-btn {
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.codici-tab-btn:hover { background: var(--hover); color: var(--text); }
.codici-tab-btn--active {
  background: #fff;
  color: var(--text);
  font-weight: 700;
  border-color: var(--line);
  position: relative;
  bottom: -1px;
}

.codici-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.3rem;
}

.codici-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: #607d8b;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #f0f4f7;
}

.codici-product-hd {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  margin: 1.1rem 0 0.4rem;
  padding-top: 0.75rem;
  border-top: 1px solid #f0f4f7;
}
.codici-product-hd:first-of-type { padding-top: 0; border-top: none; margin-top: 0; }

.codici-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #90a4ae;
  margin: 0.75rem 0 0.3rem;
}
.codici-section-label:first-child { margin-top: 0; }

.codici-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.codici-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 7px;
  background: var(--background);
}
.codici-item--main {
  background: #e8f4fd;
  border: 1px solid #b3d9f7;
}

.codici-code {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  min-width: 100px;
}
.codici-item--main .codici-code { color: #1565c0; }

.codici-desc {
  font-size: 0.80rem;
  color: #607d8b;
  line-height: 1.3;
}

.codici-empty {
  text-align: center;
  color: #90a4ae;
  padding: 2rem 0;
  font-size: 0.88rem;
}

.codici-footer {
  display: flex;
  gap: 8px;
  padding: 0.9rem 1.3rem;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

/* ── Moduli creati ────────────────────────────────────────── */
.mod-page { overflow: hidden; height: 100vh; }

.mod-layout {
  height: calc(100vh - 72px);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 2rem 1rem;
  gap: 0.75rem;
  box-sizing: border-box;
}

.mod-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 1rem;
}
.mod-header h1 { margin: 0; }

.mod-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.mod-search-wrap {
  position: relative;
}
.mod-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: #90a4ae;
  pointer-events: none;
}
.mod-search {
  padding: 7px 12px 7px 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.84rem;
  background: #fff;
  outline: none;
  width: 240px;
  transition: border-color 0.15s;
}
.mod-search:focus { border-color: var(--teal); }

.ass-search-wrap { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.ass-search-wrap .mod-search { width: 220px; }
.ass-search-column {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.82rem;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}
.ass-search-column:focus { border-color: var(--teal); }

.mod-table-wrapper {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.mod-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}
.mod-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--background);
}
.mod-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: #607d8b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
}
.mod-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.mod-table tbody tr:last-child td { border-bottom: none; }
.mod-table tbody tr:hover { background: #f9fbfc; }

.mod-cell-code {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.80rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}
.mod-cell-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.mod-cell-actions {
  text-align: right;
  white-space: nowrap;
}

.mod-edit-btn { font-size: 1rem; }
.mod-del-btn  { font-size: 0.9rem; color: #c0392b; }

.mod-empty {
  text-align: center;
  color: #90a4ae;
  padding: 2.5rem 1rem;
  font-size: 0.9rem;
}

/* modal moduli */
.mod-overlay {
  position: fixed;
  inset: 0;
  background: rgba(23,37,49,.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mod-modal {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.mod-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.3rem 0.9rem;
  border-bottom: 1px solid var(--line);
}
.mod-modal-head h3 { margin: 0; font-size: 1rem; }

.mod-form {
  padding: 1.2rem 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.mod-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* ─── Controllo Budget ─────────────────────────────────────────────────────── */

.dash-card--budget { --card-accent: #2e7d32; }

.budget-layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 44px clamp(18px, 4vw, 44px) 80px;
}

.budget-header { margin-bottom: 28px; }
.budget-header > p { color: var(--muted); margin: 0; max-width: 70ch; }

.budget-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
}

/* Area di caricamento */
.budget-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 38px 28px;
  border: 2px dashed var(--line);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
  color: var(--muted);
  font-weight: 450;
}

.budget-drop:hover,
.budget-drop--drag { border-color: var(--teal); background: #f3f8f5; }
.budget-drop--has-file { border-style: solid; border-color: var(--teal); background: #f3f8f5; }
.budget-drop svg { width: 40px; height: 40px; opacity: 0.5; }
.budget-drop-text { font-size: 0.95rem; color: var(--ink); }
.budget-drop-hint { font-size: 0.8rem; }
.budget-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.budget-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

/* Salvataggio in archivio: un tasto per mercato */
.budget-salva { margin-top: 24px; }
.budget-salva .budget-actions { flex-wrap: wrap; }
.budget-salva-titolo { margin: 0; font-size: 1rem; color: var(--ink); }
.budget-salva-testo { margin: 6px 0 0; font-size: 0.85rem; color: var(--muted); }

.budget-salva-conteggi {
  margin: 14px 0 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--muted);
}

/* Blocchi contrattuali dentro un documento */
.budget-contratto {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.budget-contratto:first-of-type { border-top: none; padding-top: 0; }

.budget-contratto-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 10px;
}

.budget-contratto-head h3 {
  margin: 0;
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--teal-dark);
}

.budget-contratto-date { margin: 0; font-size: 0.8rem; color: var(--muted); }

.budget-totale-doc {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 2px solid var(--line);
}

.budget-totale-doc div { display: flex; flex-direction: column; gap: 2px; }
.budget-totale-doc dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 700; color: var(--muted); }
.budget-totale-doc dd { margin: 0; font-size: 1rem; font-weight: 700; color: var(--ink); }

/* Archivio dei documenti salvati, diviso per mercato */
.budget-archivio { margin-top: 40px; }

.budget-archivio-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.budget-archivio-head h2 { margin: 4px 0 0; font-size: 1.35rem; }
.budget-mercato-tabs { display: flex; gap: 10px; flex-wrap: wrap; }

.budget-tab-conta {
  display: inline-block;
  min-width: 20px;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--background);
  font-size: 0.78rem;
  font-weight: 700;
}

.tier-tab--active .budget-tab-conta { background: var(--paper); color: var(--teal-dark); }

.budget-prodotti { margin-top: 24px; }
.budget-prodotti-titolo { margin: 0 0 14px; font-size: 1rem; color: var(--ink); }

.budget-prodotti-nota { margin: -8px 0 14px; font-size: 0.8rem; color: var(--muted); }

/* Riepilogo per cliente: una riga per cliente, il dettaglio per macro
   categoria si apre cliccando sulla riga. */
.budget-tabella-clienti .budget-riga-cliente td {
  border-top: 1px solid var(--line);
}

.budget-tabella-clienti tbody tr:first-child td { border-top: none; }

.budget-espandi-freccia {
  color: var(--teal);
  font-size: 1.1rem;
  line-height: 1;
  transition: transform 0.15s;
}

[aria-expanded="true"] .budget-espandi-freccia { transform: rotate(90deg); }

.budget-categoria-tag {
  display: inline-block;
  margin: 1px 2px 1px 0;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* Disdette inserite a mano */
.budget-disdetta { margin-top: 24px; }
.budget-disdetta summary { cursor: pointer; list-style: none; }
.budget-disdetta summary::-webkit-details-marker { display: none; }
.budget-disdetta-titolo { display: block; font-size: 1rem; font-weight: 700; color: var(--ink); }
.budget-disdetta-testo { display: block; margin-top: 4px; font-size: 0.85rem; color: var(--muted); }
.budget-disdetta summary::before { content: "+ "; color: var(--teal); font-weight: 700; }
.budget-disdetta details[open] summary::before,
.budget-disdetta[open] summary::before { content: "− "; }

.budget-disdetta-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.budget-disdetta-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.budget-disdetta-form input,
.budget-disdetta-form select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font: inherit;
  font-size: 0.9rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
}

.budget-disdetta-form input:focus,
.budget-disdetta-form select:focus { outline: 2px solid var(--teal); outline-offset: -1px; border-color: var(--teal); }
.budget-disdetta-largo { grid-column: 1 / -1; }
.budget-disdetta-azioni { display: flex; align-items: flex-end; }
.budget-doc--disdetta { border-left: 4px solid #c0392b; }

.budget-badge--disdetta { background: #fdecea; color: #c0392b; }
.budget-num--neg { color: #c0392b; }

/* Totali per linea prodotto */
.budget-tabella-linee { min-width: 780px; }
.budget-tabella-linee .budget-num--forte { font-weight: 700; color: var(--ink); }

.budget-peso {
  position: relative;
  min-width: 120px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.budget-peso-barra {
  position: absolute;
  left: 8px;
  right: auto;
  bottom: 4px;
  height: 4px;
  max-width: calc(100% - 16px);
  border-radius: 999px;
  background: var(--teal);
}

.budget-peso-valore { font-weight: 600; }

/* Riepilogo su quattro colonne: cod. utente, ragione sociale, linea, canone */
.budget-tabella-clienti td, .budget-tabella-clienti th { white-space: nowrap; }
.budget-tabella-clienti td:nth-child(2) { white-space: normal; }
.budget-col-codice { font-variant-numeric: tabular-nums; color: var(--muted); }
.budget-col-data { font-variant-numeric: tabular-nums; white-space: nowrap; }

.budget-riga-cliente { cursor: pointer; }
.budget-riga-cliente:hover td, .budget-riga-cliente:focus-visible td { background: var(--teal-soft); }
.budget-riga-cliente[aria-expanded="true"] td { background: var(--teal-soft); }

.budget-espandi-freccia { display: inline-block; margin-right: 6px; }

.budget-riga-categoria td {
  background: var(--background);
  color: var(--muted);
  font-size: 0.82rem;
  padding-top: 5px;
  padding-bottom: 5px;
  border-top: none;
}

.budget-riga-categoria { cursor: pointer; }
.budget-riga-categoria:hover td, .budget-riga-categoria:focus-visible td { color: var(--ink); }
.budget-riga-categoria td:nth-child(3) { font-weight: 700; color: var(--ink); }

/* Terzo livello: le singole righe prodotto dentro la linea */
.budget-riga-prodotto td {
  background: var(--background);
  color: var(--muted);
  font-size: 0.78rem;
  padding-top: 4px;
  padding-bottom: 4px;
  border-top: 1px dotted var(--line);
}

.budget-riga-prodotto td:nth-child(3) { padding-left: 28px; }
.budget-riga-prodotto strong { font-weight: 700; color: var(--ink); }
.budget-ids-inline { font-size: 0.72rem; color: var(--teal-dark); }

.budget-archivio-vuoto {
  margin: 24px 0 0;
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.budget-doc-azioni { display: flex; align-items: center; gap: 10px; }
.budget-doc-azioni .tier-tab { margin-left: 0; padding: 5px 14px; font-size: 0.8rem; }

/* Riepilogo complessivo */
.budget-riepilogo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.budget-kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.budget-kpi-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--muted);
}

.budget-kpi strong { font-size: 1.15rem; color: var(--ink); }

/* Accesso alla schermata di dettaglio dei documenti letti */
.budget-vista-azioni { display: flex; justify-content: flex-end; margin-top: 16px; }

.budget-dettaglio-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.budget-dettaglio-head h1 { margin: 4px 0 0; }
.budget-dettaglio-nota { color: var(--muted); margin: 6px 0 0; max-width: 70ch; }
.budget-dettaglio-head .feedback { margin: 10px 0 0; }

/* Scheda per documento */
.budget-risultati { display: flex; flex-direction: column; gap: 18px; margin-top: 24px; }

.budget-doc {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 24px;
  box-shadow: var(--shadow);
}

.budget-doc--errore { border-color: #f0c2c2; background: #fdf6f6; }
.budget-doc-errore { margin: 0; color: #b91c1c; font-size: 0.88rem; }

.budget-doc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.budget-doc-head h2 { margin: 0; font-size: 1.05rem; }
.budget-doc-file { margin: 4px 0 0; font-size: 0.8rem; color: var(--muted); }

.budget-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.budget-badge--ok { background: #e8f5e9; color: #2e7d32; }
.budget-badge--warn { background: #fff4e5; color: #b45309; }

.budget-dati {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 0 0 16px;
}

.budget-dati dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 3px;
}

.budget-dati dd { margin: 0; font-size: 0.92rem; color: var(--ink); }

.budget-avvisi {
  margin: 0 0 16px;
  padding: 10px 14px 10px 28px;
  background: #fff4e5;
  border-radius: 10px;
  color: #92400e;
  font-size: 0.82rem;
}

.budget-avvisi li { margin: 2px 0; }

.budget-tabella-wrap { overflow-x: auto; }

.budget-tabella {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.budget-tabella th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  white-space: nowrap;
}

.budget-tabella td {
  padding: 9px 10px;
  border-bottom: 1px solid #eef1ef;
  color: var(--ink);
  vertical-align: top;
}

.budget-tabella tfoot td {
  border-bottom: 0;
  border-top: 2px solid var(--line);
  font-weight: 700;
}

.budget-tabella th.budget-num,
.budget-tabella td.budget-num { text-align: right; white-space: nowrap; }

.budget-tabella .budget-num:nth-child(n+4) { font-variant-numeric: tabular-nums; }

.budget-ids {
  display: block;
  margin-top: 2px;
  font-size: 0.74rem;
  color: var(--muted);
}

.budget-vuoto { text-align: center; color: var(--muted); padding: 18px 0; }

/* ─── Rubrica clienti: tendina di scelta colonne ───────────────────────────── */

.cli-colonne {
  position: relative;
}

.cli-colonne-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cli-colonne-caret {
  opacity: 0.55;
  transition: transform 0.15s;
}

.cli-colonne-btn[aria-expanded="true"] .cli-colonne-caret {
  transform: rotate(180deg);
}

.cli-colonne-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  min-width: 200px;
  padding: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14);
}

.cli-colonne-lista {
  display: flex;
  flex-direction: column;
  max-height: min(60vh, 440px);
  overflow-y: auto;
}

/* flex-direction e width sono esplicite perché le regole globali di questo
   foglio impostano label in colonna e input al 100% della larghezza. */
.cli-colonne-voce {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 7px;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}

.cli-colonne-voce:hover {
  background: #f4f7f5;
}

.cli-colonne-voce input {
  width: auto;
  flex: none;
  margin: 0;
  padding: 0;
  cursor: pointer;
  accent-color: var(--teal);
}

.cli-colonne-voce span {
  white-space: nowrap;
}

.cli-colonne-voce--fissa {
  color: var(--muted);
  cursor: default;
}

.cli-colonne-voce--fissa:hover {
  background: transparent;
}

.cli-colonne-voce--fissa input {
  cursor: default;
}

.cli-colonne-reset {
  width: 100%;
  margin-top: 6px;
  padding: 6px 8px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0 0 7px 7px;
  background: transparent;
  font: inherit;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
}

.cli-colonne-reset:hover {
  color: var(--ink);
}

/* Il bottone principale del budget non deve occupare tutta la riga */
.budget-actions .save-button { width: auto; padding-inline: 26px; }

/* ── Agenda ───────────────────────────────────────────────────────────────── */

.ag-layout {
  height: calc(100vh - 72px);
  display: flex;
  flex-direction: column;
  padding: 16px clamp(14px, 2.5vw, 32px) 18px;
  overflow: hidden;
}

.ag-toolbar {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.ag-toolbar-nav { display: flex; align-items: center; gap: 12px; }
.ag-toolbar-azioni { display: flex; align-items: center; gap: 12px; }

.ag-titolo {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 750;
  text-transform: capitalize;
  white-space: nowrap;
}

.ag-oggi { padding: 8px 16px; }
.ag-frecce { display: flex; gap: 3px; }
.ag-freccia {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 9px;
  color: var(--muted);
  cursor: pointer;
}
.ag-freccia:hover { background: var(--background); color: var(--ink); }

.ag-viste {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--background);
}
.ag-vista-tab {
  border: none;
  background: none;
  padding: 7px 16px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.ag-vista-tab:hover { color: var(--ink); }
.ag-vista-tab--active {
  background: var(--paper);
  color: var(--teal-dark);
  box-shadow: 0 1px 3px rgba(20, 39, 46, 0.12);
}
.ag-nuovo { width: auto; padding-inline: 20px; }

.ag-feedback { margin: 0 0 10px; font-size: 0.85rem; font-weight: 600; }
.ag-feedback--ok { color: #2e7d32; }
.ag-feedback--errore { color: #c62828; }

.ag-corpo { flex: 1; min-height: 0; display: flex; }

/* ── Colori per tipo di impegno ── */
.ag-t--appuntamento { --ag-c: #1565c0; --ag-cs: #e8f1fb; }
.ag-t--visita       { --ag-c: #2e7d32; --ag-cs: #e9f5ea; }
.ag-t--chiamata     { --ag-c: #6a1b9a; --ag-cs: #f3e9f8; }
.ag-t--scadenza     { --ag-c: #c62828; --ag-cs: #fceaea; }
.ag-t--formazione   { --ag-c: #ef6c00; --ag-cs: #fdf0e3; }
.ag-t--personale    { --ag-c: #00695c; --ag-cs: #e4f1ef; }
.ag-t--altro        { --ag-c: #546e7a; --ag-cs: #eef1f3; }

/* Colori scelti a mano: vengono dopo i colori per tipo, quindi li sostituiscono */
.ag-c--pomodoro    { --ag-c: #c62828; --ag-cs: #fceaea; }
.ag-c--mandarino   { --ag-c: #e65100; --ag-cs: #fdeee1; }
.ag-c--banana      { --ag-c: #8d6e00; --ag-cs: #faf2d8; }
.ag-c--basilico    { --ag-c: #2e7d32; --ag-cs: #e9f5ea; }
.ag-c--salvia      { --ag-c: #00695c; --ag-cs: #e4f1ef; }
.ag-c--pavone      { --ag-c: #0277bd; --ag-cs: #e4f2fb; }
.ag-c--mirtillo    { --ag-c: #1a3e8c; --ag-cs: #e7ecf7; }
.ag-c--lavanda     { --ag-c: #5e35b1; --ag-cs: #eee9f8; }
.ag-c--uva         { --ag-c: #6a1b9a; --ag-cs: #f3e9f8; }
.ag-c--fenicottero { --ag-c: #ad1457; --ag-cs: #fbe6ef; }
.ag-c--grafite     { --ag-c: #455a64; --ag-cs: #eceff1; }

/* ── Vista mese ── */
.ag-mese {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--paper);
}
.ag-dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--line);
  background: var(--background);
}
.ag-dow-corto { display: none; }

.ag-dow-cella {
  padding: 8px 10px;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.ag-mese-griglia {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, 1fr);
}
.ag-cella {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  padding: 4px 5px 5px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  cursor: pointer;
}
.ag-cella:nth-child(7n) { border-right: none; }
.ag-cella:nth-child(n + 36) { border-bottom: none; }
.ag-cella:hover { background: #fafcfb; }
.ag-cella--weekend { background: #fcfdfd; }
.ag-cella--fuori { background: #f8fafa; }
.ag-cella-testa { display: flex; justify-content: center; flex: none; }
.ag-numero {
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  border-radius: 50%;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}
.ag-numero:hover { background: var(--teal-soft); }
.ag-cella--fuori .ag-numero { color: #a6b4bb; }
.ag-numero--oggi, .ag-numero--oggi:hover { background: var(--teal); color: #fff; }
.ag-cella-lista { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.ag-altri {
  flex: none;
  border: none;
  background: none;
  padding: 1px 5px;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}
.ag-altri:hover { color: var(--teal-dark); }

/* ── Chip di un impegno ── */
.ag-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  padding: 2px 6px;
  border: none;
  border-left: 3px solid var(--ag-c, #546e7a);
  border-radius: 4px;
  background: var(--ag-cs, #eef1f3);
  color: var(--ag-c, #546e7a);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
}
.ag-chip:hover { filter: brightness(0.96); }
.ag-chip-ora { flex: none; opacity: 0.85; font-variant-numeric: tabular-nums; }
.ag-chip-testo { overflow: hidden; text-overflow: ellipsis; }
.ag-chip-prog { flex: none; margin-left: auto; font-size: 0.65rem; opacity: 0.7; }
.ag-chip--fatto .ag-chip-testo { text-decoration: line-through; opacity: 0.6; }

/* ── Viste settimana e giorno ── */
.ag-tempo {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--paper);
}
.ag-tempo-testa { display: flex; flex: none; border-bottom: 1px solid var(--line); background: var(--background); }
.ag-gutter { width: 58px; flex: none; }
.ag-testa-giorni { flex: 1; display: grid; grid-template-columns: repeat(var(--ag-giorni, 7), 1fr); }
.ag-testa-giorno { padding: 6px 4px 8px; text-align: center; border-left: 1px solid var(--line); }
.ag-testa-dow {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.ag-testa-giorno--oggi .ag-testa-dow { color: var(--teal); }
.ag-testa-num {
  width: 32px;
  height: 32px;
  margin-top: 3px;
  border: none;
  background: none;
  border-radius: 50%;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}
.ag-testa-num:hover { background: var(--teal-soft); }

.ag-tuttogiorno-riga {
  display: flex;
  flex: none;
  max-height: 96px;
  overflow-y: auto;
  border-bottom: 1px solid var(--line);
  background: #fbfdfc;
}
.ag-gutter--tg {
  padding: 6px 6px 0;
  text-align: right;
  line-height: 1.2;
  font-size: 0.62rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.ag-tuttogiorno-celle { flex: 1; display: grid; grid-template-columns: repeat(var(--ag-giorni, 7), 1fr); }
.ag-tg-cella {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 32px;
  padding: 4px;
  border-left: 1px solid var(--line);
  cursor: pointer;
}
.ag-chip--tg { font-size: 0.74rem; padding: 3px 6px; }

.ag-tempo-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.ag-tempo-corpo { display: flex; }
.ag-gutter--ore { display: flex; flex-direction: column; }
.ag-ora { height: 48px; position: relative; }
.ag-ora span {
  position: absolute;
  top: -8px;
  right: 8px;
  font-size: 0.7rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.ag-colonne { flex: 1; display: grid; grid-template-columns: repeat(var(--ag-giorni, 7), 1fr); }
.ag-colonna { position: relative; border-left: 1px solid var(--line); cursor: pointer; }
.ag-colonna--oggi { background: #fffdfa; }
.ag-slot { height: 48px; border-bottom: 1px solid #eef2f3; }
.ag-adesso {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--teal);
  z-index: 3;
  pointer-events: none;
}
.ag-adesso-pallino {
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--teal);
}
.ag-blocco {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 6px;
  border: none;
  border-left: 3px solid var(--ag-c, #546e7a);
  border-radius: 5px;
  background: var(--ag-cs, #eef1f3);
  color: var(--ag-c, #546e7a);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  text-align: left;
  overflow: hidden;
  cursor: pointer;
}
.ag-blocco:hover { filter: brightness(0.96); z-index: 4; }
/* Impegni brevi: ora e titolo affiancati, altrimenti il testo verrebbe tagliato */
.ag-blocco--basso { flex-direction: row; align-items: baseline; gap: 6px; padding-top: 1px; }
.ag-blocco--basso .ag-blocco-ora { flex: none; }
.ag-blocco--basso .ag-blocco-sub { display: none; }
.ag-blocco-ora { font-size: 0.68rem; opacity: 0.85; font-variant-numeric: tabular-nums; }
.ag-blocco-titolo, .ag-blocco-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-blocco-sub { font-size: 0.68rem; font-weight: 500; opacity: 0.8; }
.ag-blocco--fatto .ag-blocco-titolo { text-decoration: line-through; opacity: 0.65; }

/* ── Scheda dell'impegno ── */
.ass-drawer--agenda { width: min(540px, 100vw); }
.ag-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding-top: 8px; }
.ag-campo {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.ag-campo--largo { grid-column: 1 / -1; }
.ag-campo input, .ag-campo select, .ag-campo textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}
.ag-campo textarea { resize: vertical; }
.ag-campo input:focus, .ag-campo select:focus, .ag-campo textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 2px var(--teal-soft);
}
.ag-check {
  flex-direction: row;
  align-items: center;
  gap: 9px;
  align-self: end;
  padding-bottom: 9px;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  cursor: pointer;
}
.ag-check input { width: auto; accent-color: var(--teal); }
.ag-form-errore { grid-column: 1 / -1; margin: 0; font-size: 0.85rem; font-weight: 600; color: #c62828; }
.ag-form-azioni { grid-column: 1 / -1; }
.ag-elimina { margin-left: auto; }

@media (max-width: 900px) {
  .ag-form { grid-template-columns: 1fr; }
  .ag-titolo { font-size: 1.1rem; }
}

/* ── Selettore colore e flag sede nella scheda impegno ── */
.ag-colori-campo {
  margin: 0;
  padding: 0;
  border: none;
}
.ag-colori-campo legend {
  padding: 0 0 7px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.ag-colori { display: flex; flex-wrap: wrap; gap: 8px; }
.ag-colore { cursor: pointer; line-height: 0; }
.ag-colore input { position: absolute; opacity: 0; width: 0; height: 0; }
.ag-colore-pallino {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ag-c, #546e7a);
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 2px transparent;
  transition: box-shadow 0.12s;
}
.ag-colore-pallino--auto {
  background: var(--background);
  border: 1px dashed var(--line);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1;
}
.ag-colore:hover .ag-colore-pallino { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--line); }
.ag-colore input:checked + .ag-colore-pallino {
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink);
}
.ag-colore input:focus-visible + .ag-colore-pallino {
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--teal);
}

.ag-sede { align-self: start; padding-bottom: 0; }
.ag-sede-hint { font-weight: 500; color: var(--muted); font-size: 0.85rem; }

/* ══════════════════════════════════════════════════════════════════════════════
   MOBILE
   Tutto ciò che riguarda smartphone e tablet in verticale sta qui, chiuso nelle
   media query: sopra gli 860px non cambia niente rispetto a prima.

   Il guaio principale non era il singolo elemento fuori misura ma la barra di
   navigazione: 977px di link su 390px di schermo. Il telefono, per far stare
   tutto, rimpiccioliva la pagina intera a un terzo. In più .ass-page e
   .mod-page bloccano lo scorrimento (overflow:hidden + height:100vh) perché su
   desktop la pagina deve stare esatta in una schermata: su telefono questo
   impedisce di raggiungere il contenuto, quindi lì si torna allo scorrimento
   normale della pagina.
   ══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 860px) {

  /* ── Barra superiore: loghi sopra, menu che scorre di lato sotto ── */
  .topbar {
    height: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 10px 14px 0;
  }
  .brand-logo { height: 30px; }
  .brand-logo--sistemi { height: 32px; }
  .topbar-nav {
    gap: 2px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .topbar-nav::-webkit-scrollbar { display: none; }
  .topbar-link { flex: none; padding: 7px 13px; font-size: 0.86rem; }

  /* ── Pagine bloccate a una schermata: su telefono scorre la pagina ── */
  .ass-page, .mod-page { overflow: visible; height: auto; }
  .ass-layout, .ag-layout, .mod-layout {
    height: auto;
    overflow: visible;
    padding: 14px 14px 34px;
  }
  .layout { padding: 18px 14px 40px; }
  .listini-layout { padding: 18px 14px 48px; }
  .budget-layout { padding: 18px 14px 48px; }
  .dash-layout { padding: 26px 16px 60px; gap: 32px; }
  .arco-main { padding: 18px 14px 48px; }

  /* ── Intestazioni di pagina: a capo invece di stringersi ── */
  .ass-header, .mod-header {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
  }
  .ass-search-wrap, .mod-header-actions {
    margin-left: 0;
    width: 100%;
    flex-wrap: wrap;
  }
  .ass-search-wrap .mod-search, .mod-search { width: 100%; }
  .mod-search-wrap { flex: 1 1 100%; min-width: 0; }

  /* Senza min-width:0 un elemento in flex o grid non scende sotto la larghezza
     del suo contenuto: il riquadro con lo scorrimento non si restringe e la
     tabella sfonda la pagina invece di scorrere. */
  .config-split,
  .config-split-group,
  .config-split-group > *,
  .listini-sections > * { min-width: 0; }

  /* ── Tabelle larghe: scorrono di lato dentro il loro riquadro ── */
  .ass-table-wrapper, .mod-table-wrapper, .listini-section, .budget-card {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .ass-table-wrapper, .mod-table-wrapper { max-height: 70vh; }
  .ass-table, .mod-table, .listini-table, .budget-tabella { font-size: 0.78rem; }

  /* Gruppi di bottoni in fila: vanno a capo invece di sfondare la pagina */
  .listino-tipo-toggle,
  .product-filter,
  .budget-actions,
  .preview-toolbar,
  .listini-page-header { flex-wrap: wrap; }
  .listino-tipo-btn { padding: 7px 14px; font-size: 0.82rem; }

  /* La colonna con il pulsante ⋮ resta agganciata al bordo destro: la tabella
     scorre di lato e altrimenti il pulsante per aprire la scheda finirebbe
     fuori schermo. */
  .ass-table .ass-actions {
    position: sticky;
    right: 0;
    background: #fff;
    box-shadow: -6px 0 8px -6px rgba(20, 39, 46, 0.18);
  }
  .ass-table thead .ass-actions { background: var(--background); }
  .ass-menu-btn { padding: 5px 10px; }

  /* ── Schede laterali a tutta larghezza ── */
  .ass-drawer { height: 100dvh; }
  .scheda-griglia { grid-template-columns: 1fr; }

  /* Titoli: su 390px il titolo grande da desktop occupa tre righe */
  h1 { font-size: 1.6rem; }
  .intro { margin-bottom: 22px; }
  /* Le righe di messaggio vuote lasciano un vuoto inspiegabile */
  .feedback:empty, .ag-feedback:empty { display: none; }

  /* ── Agenda ── */
  .ag-toolbar { gap: 10px; margin-bottom: 10px; }
  .ag-toolbar-nav { width: 100%; justify-content: flex-start; gap: 8px; }
  .ag-toolbar-azioni { width: 100%; flex-wrap: wrap; gap: 8px; }
  .ag-titolo { font-size: 1.05rem; }
  /* Le tre viste si dividono la riga, il pulsante nuovo prende quella dopo:
     a metà larghezza la sua scritta andava a capo */
  .ag-viste { flex: 1 1 100%; }
  .ag-vista-tab { flex: 1; padding: 8px 6px; font-size: 0.82rem; }
  .ag-nuovo { flex: 1 1 100%; width: 100%; white-space: nowrap; }
  /* Nel mese ci sta solo l'abbreviazione del giorno */
  .ag-dow-lungo { display: none; }
  .ag-dow-corto { display: inline; }

  /* Nel mese la cella è larga ~50px: il testo non si legge, restano le barrette
     colorate e si toca il giorno per aprirlo in dettaglio. */
  .ag-mese-griglia { grid-template-rows: repeat(6, minmax(72px, auto)); }
  .ag-dow-cella { padding: 6px 2px; font-size: 0.58rem; letter-spacing: 0.02em; }
  .ag-cella { padding: 3px 3px 4px; }
  .ag-numero { width: 22px; height: 22px; font-size: 0.75rem; }
  .ag-mese .ag-chip {
    height: 6px;
    padding: 0;
    border-left: none;
    border-radius: 3px;
    background: var(--ag-c, #546e7a);
  }
  .ag-mese .ag-chip-ora,
  .ag-mese .ag-chip-testo,
  .ag-mese .ag-chip-prog { display: none; }
  .ag-altri { padding: 0 3px; font-size: 0.62rem; }

  /* Settimana: colonne di larghezza leggibile, si scorre di lato.
     Testa, riga "tutto il giorno" e griglia restano allineate perché scorrono
     insieme dentro .ag-tempo. */
  .ag-tempo { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .ag-tempo-testa, .ag-tuttogiorno-riga, .ag-tempo-corpo {
    min-width: calc(46px + var(--ag-giorni, 7) * 96px);
  }
  .ag-gutter { width: 46px; }
  .ag-gutter--tg { font-size: 0.5rem; line-height: 1.15; padding: 5px 4px 0; }
  .ag-ora span { right: 5px; font-size: 0.62rem; }
  .ag-tempo-scroll { max-height: 62vh; }
  .ag-testa-num { width: 28px; height: 28px; font-size: 0.95rem; }

  /* ── Anteprima A4: resta a 210mm (la paginazione dipende da quella misura),
     quindi si scorre di lato solo lei ── */
  .live-preview, .arco-preview { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .preview-toolbar { max-width: none; }

  /* ── Campi: 16px impedisce a iOS di zoomare da solo quando si scrive ── */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select,
  textarea {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .topbar { padding-inline: 10px; }
  .ass-layout, .ag-layout, .mod-layout,
  .layout, .listini-layout, .budget-layout { padding-inline: 10px; }
  .ag-toolbar-nav { gap: 8px; }
  .ag-titolo { font-size: 0.98rem; }
  .ag-oggi { padding: 8px 12px; }
  .scheda-azioni { flex-wrap: wrap; }
  .ag-elimina { margin-left: 0; }
}

/* ── Tablet e portatili (861-1440px) ───────────────────────────────────────────
   Qui il layout desktop va bene, i problemi sono due: i nove collegamenti non
   stanno in una riga (la barra resta su una riga sola ma scorre di lato) e su
   1366px, larghezza comunissima da portatile, la tabella dei listini sfondava.
   Sono regole permissive — consentono di restringersi e scorrere — quindi non
   cambiano niente dove già ci stava tutto. */
@media (max-width: 1440px) {
  .brand { flex: none; }
  .topbar-nav {
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .topbar-nav::-webkit-scrollbar { display: none; }
  .topbar-link { flex: none; }

  /* Stessa ragione del blocco mobile: senza min-width:0 il riquadro con lo
     scorrimento non si restringe e la tabella dei listini sfonda la pagina. */
  .config-split,
  .config-split-group,
  .config-split-group > * { min-width: 0; }
}
