/* ============================================================
   JEWEL FIX - CSS Stylesheet v3
   Tema chiaro / leggero - bianco predominante
   ============================================================ */

:root {
  --c-bg:       #f0f2f7;
  --c-surface:  #ffffff;
  --c-surface2: #f8f9fc;
  --c-border:   #dde1ea;
  --c-border2:  #c8cdd8;
  --c-primary:  #667eea;
  --c-primary2: #764ba2;
  --c-text:     #1e1e2e;
  --c-text-dim: #6b7280;
  --c-text-ph:  #9ca3af;
  --c-danger:   #ef4444;
  --radius:     12px;
  --radius-sm:  8px;
  --shadow:     0 2px 12px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 20px rgba(0,0,0,0.12);
  --btn-grad:   linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --btn-grad-h: linear-gradient(135deg, #7c8ef5 0%, #8a5cb8 100%);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  min-height: 100vh;
  padding: 12px;
}

/* ============================================================
   HEADER
   ============================================================ */
.intestazione {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 16px;
  margin-bottom: 12px;
}

.header {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  grid-template-rows: auto auto;
  gap: 6px 12px;
  align-items: center;
  max-width: 1440px;
  margin: 0 auto;
}

#logoLandolfo {
  max-width: 420px;
  width: 100%;
  height: auto;
  border-left: 2px solid var(--c-border);
  border-right: 2px solid var(--c-border);
  padding: 0 20px;
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
}

#logoMorellato {
  max-width: 170px;
  width: 100%;
  height: auto;
  grid-column: 1;
  grid-row: 1;
  justify-self: center;
}

#logoDestra {
  max-width: 170px;
  width: 100%;
  height: auto;
  grid-column: 3;
  grid-row: 1;
  justify-self: center;
}

.contatti {
  font-size: 0.74em;
  line-height: 1.4;
  text-align: center;
  color: var(--c-text-dim);
  grid-row: 2;
}
.contatti strong { color: var(--c-text); }
.contatti.contatti-sinistra { grid-column: 1; }
.contatti.contatti-centro  { grid-column: 2; }
.contatti.contatti-destra  { grid-column: 3; }
.contatti div { margin-bottom: 1px; }

/* ============================================================
   TITOLO PAGINA
   ============================================================ */
h2#numNeg {
  text-align: center;
  color: var(--c-primary2);
  margin: 12px 0 10px;
  font-size: 1.5em;
  font-weight: 700;
}

/* ============================================================
   LOGIN MODAL
   ============================================================ */
#loginModal {
  position: fixed;
  inset: 0;
  background: rgba(15,14,40,0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  padding: 16px;
}

#loginBox {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  width: min(380px, 100%);
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease-out;
  overflow: hidden;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-card-header {
  background: var(--btn-grad);
  padding: 20px 22px 16px;
  text-align: center;
}

.login-card-header #minilogoLandolfo {
  display: block !important;
  width: min(200px, 70%) !important;
  height: auto !important;
  margin: 0 auto 10px;
}

.login-card-header h3 {
  font-size: 1.2em;
  font-weight: 700;
  color: white;
  margin-bottom: 3px;
}

.login-card-header p {
  font-size: 0.8em;
  color: rgba(255,255,255,0.75);
}

.login-card-body { padding: 22px 22px 24px; }

.login-field { margin-bottom: 14px; }

.login-field label {
  display: block;
  font-weight: 600;
  font-size: 0.8em;
  color: var(--c-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}

.login-field input {
  width: 100%;
  padding: 11px 12px;
  background: var(--c-surface2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  color: var(--c-text);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.login-field input:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(102,126,234,0.15);
  background: #fff;
}

.login-field input::placeholder { color: var(--c-text-ph); }

.login-field .password-container { position: relative; }
.login-field .password-container input { padding-right: 42px; }

.login-field .toggle-password {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--c-text-dim);
  font-size: 1em;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}
.login-field .toggle-password:hover { color: var(--c-primary); }

.login-btn {
  width: 100%;
  margin-top: 4px;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  justify-content: center;
}

.login-hint {
  margin-top: 12px;
  text-align: center;
  font-size: 0.78em;
  color: var(--c-text-dim);
}

/* vecchio #loginBox label/input - neutralizzati */
#loginBox > label { display: none; }

/* ============================================================
   BOTTONI
   ============================================================ */
.btnBase {
  background: var(--btn-grad);
  color: #fff;
  font-weight: 600;
  border: none;
  padding: 8px 14px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  user-select: none;
  font-family: 'Segoe UI', sans-serif;
  font-size: 0.86em;
  box-shadow: 0 2px 8px rgba(102,126,234,0.25);
  white-space: nowrap;
}

.btnBase:hover {
  background: var(--btn-grad-h);
  box-shadow: 0 4px 14px rgba(102,126,234,0.4);
  transform: translateY(-1px);
}

.btnBase:active { transform: translateY(0); box-shadow: none; }
.btnBase i { margin-right: 4px; }

.btnIcona { padding: 7px 9px; min-width: 32px; }
.btnModifica { font-size: 0.8em; padding: 5px 8px; }

#btnInvia.attivo {
  background: linear-gradient(135deg, #ef4444, #f97316);
  box-shadow: 0 0 16px rgba(239,68,68,0.45);
  animation: lampeggiaFigo 1.5s ease-in-out infinite alternate;
}

@keyframes lampeggiaFigo {
  0%   { box-shadow: 0 0 12px rgba(239,68,68,0.45); transform: scale(1); }
  100% { box-shadow: 0 0 24px rgba(249,115,22,0.6); transform: scale(1.03); }
}

/* ============================================================
   BARRA PULSANTI
   ============================================================ */
.barraPulsanti {
  position: sticky;
  top: 0;
  z-index: 998;
  display: none;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  padding: 8px 12px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.barraPulsanti .sinistra,
.barraPulsanti .destra {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  align-items: center;
}

.ricerca-container {
  display: flex;
  gap: 4px;
  align-items: center;
}

.input-ricerca {
  width: 130px;
  padding: 7px 10px;
  background: var(--c-surface2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: 0.88em;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--c-text);
  transition: all 0.2s;
  outline: none;
}

.input-ricerca:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 2px rgba(102,126,234,0.15);
  background: #fff;
}

.input-ricerca::placeholder {
  text-transform: none;
  font-weight: normal;
  color: var(--c-text-ph);
}

.btnRicerca { padding: 7px 10px; min-width: auto; }

/* ============================================================
   TABELLA
   ============================================================ */

.tabella-wrapper {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  margin-top: 10px;
  box-shadow: var(--shadow);
  overflow: visible;          /* ← non blocca il sticky del thead */
}

.tabella-scroll {
  overflow-x: auto;           /* ← scroll orizzontale su un div interno */
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 1160px;
  table-layout: fixed;
  border-collapse: collapse;
  background: transparent;
  overflow: visible;
}

th, td {
  color: var(--c-text);
  border-bottom: 1px solid var(--c-border);
  border-left: 1px solid var(--c-border);
  border-right: 1px solid var(--c-border);
  border-top: none;
  padding: 6px 7px;
  text-align: left;
  font-size: 0.82em;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

th:first-child, td:first-child { border-left: none; }
th:last-child,  td:last-child  { border-right: none; }

thead {
  position: sticky;
  /*top: 5px;*/
  z-index: 10;
}

th {
  position: sticky;
  background: var(--btn-grad);
  color: #fff;
  font-weight: 700;
  font-size: 0.8em;
  border-bottom: 2px solid rgba(255,255,255,0.2);
  letter-spacing: 0.1px;
}

thead tr:first-child th { border-top: none; }

tbody tr:hover {
  background: rgba(102,126,234,0.05) !important;
}

/* Larghezze colonne — INVARIATE */
table#tabellaDati th:nth-child(1),  table#tabellaDati td:nth-child(1)  { width: 75px; }
table#tabellaDati th:nth-child(2),  table#tabellaDati td:nth-child(2)  { width: 75px; }
table#tabellaDati th:nth-child(3),  table#tabellaDati td:nth-child(3)  { width: 75px; }
table#tabellaDati th:nth-child(4),  table#tabellaDati td:nth-child(4)  { width: 100px; }
table#tabellaDati th:nth-child(5),  table#tabellaDati td:nth-child(5)  { width: 95px; }
table#tabellaDati th:nth-child(6),  table#tabellaDati td:nth-child(6)  { width: 180px; }
table#tabellaDati th:nth-child(7),  table#tabellaDati td:nth-child(7)  { width: 90px; }
table#tabellaDati th:nth-child(8),  table#tabellaDati td:nth-child(8)  { width: 100px; }
table#tabellaDati th:nth-child(9),  table#tabellaDati td:nth-child(9)  { width: 100px; }
table#tabellaDati th:nth-child(10), table#tabellaDati td:nth-child(10) { width: 80px; }
table#tabellaDati th:nth-child(11), table#tabellaDati td:nth-child(11) { width: 80px; }
table#tabellaDati th:nth-child(12), table#tabellaDati td:nth-child(12) { width: 100px; }
table#tabellaDati th:nth-child(13), table#tabellaDati td:nth-child(13) { width: 50px; }
table#tabellaDati th:nth-child(14), table#tabellaDati td:nth-child(14) { width: 75px; }
table#tabellaDati th:nth-child(15), table#tabellaDati td:nth-child(15) { width: 130px; }
table#tabellaDati th:nth-child(16), table#tabellaDati td:nth-child(16) { width: 90px; text-align: center; }

table#tabellaDati td.limitato {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: help;
}

/* Divisorie — invariate */
.rigaDivisoria td {
  background: #2c3e50 !important;
  color: #fff !important;
  height: 30px;
  font-weight: bold;
  padding-left: 12px !important;
  border-left: none !important;
  border-right: none !important;
  border-top: 2px solid #1a252f !important;
  border-bottom: 2px solid #1a252f !important;
  vertical-align: middle !important;
}

.riga-trovata {
  animation: borderBlink 0.5s ease-in-out 6;
  position: relative;
  z-index: 5;
}

@keyframes borderBlink {
  0%, 100% { outline: 3px solid var(--c-primary); outline-offset: -3px; }
  50%       { outline: 3px solid rgba(102,126,234,0.15); outline-offset: -3px; }
}

.riga-selezionata {
  background: rgba(102,126,234,0.1) !important;
  outline: 2px solid var(--c-primary);
  outline-offset: -2px;
}

/* ============================================================
   FORM OVERLAY + CONTAINER
   ============================================================ */
#formOverlay {
  position: fixed;
  inset: 0;
  background: rgba(15,14,40,0.55);
  display: none;
  justify-content: center;
  align-items: flex-start;
  z-index: 999;
  overflow-y: auto;
  padding: 16px;
}

#formContainer {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  padding: 20px 18px;
  border-radius: var(--radius);
  width: min(620px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.25s ease-out;
  margin: auto;
}

#formContainer h3 {
  margin-bottom: 14px;
  color: var(--c-text);
  border-bottom: 2px solid var(--c-border);
  padding-bottom: 10px;
  font-size: 1.05em;
}

.blueTip {
  font-size: 0.7em;
  color: #3b82f6;
  font-weight: normal;
}

#formContainer label {
  display: block;
  margin-top: 10px;
  margin-bottom: 4px;
  font-weight: 600;
  font-size: 0.82em;
  color: var(--c-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

#formContainer select,
#formContainer input,
#formContainer textarea {
  width: 100%;
  padding: 9px 10px;
  background: var(--c-surface2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: 0.95em;
  color: var(--c-text);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

#formContainer select:focus,
#formContainer input:focus,
#formContainer textarea:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 2px rgba(102,126,234,0.15);
  background: #fff;
}

#formContainer input::placeholder,
#formContainer textarea::placeholder {
  color: var(--c-text-ph);
}

#formContainer input:disabled,
#formContainer select:disabled,
#formContainer textarea:disabled {
  background: #f1f3f7;
  color: #9ca3af;
  cursor: not-allowed;
  border-color: var(--c-border);
}

/* Campi blu (utente) */
.campoBlu label { color: #3b82f6; }
.campoBlu input,
.campoBlu select { border-color: #93c5fd; }

/* readonly esplicito — admin lo vede abilitato */
input[readonly] {
  background: #f1f3f7 !important;
  cursor: not-allowed !important;
}

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
#loadingOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(240,242,247,0.88);
  z-index: 2000;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 14px;
}

.loader { font-size: 2.2em; animation: spin 1.5s linear infinite; }

#loadingOverlay > div {
  font-size: 1em;
  color: var(--c-primary2);
  font-weight: 600;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   DDT / FATTURE PREVIEW
   ============================================================ */
#ddtPreviewContainer {
  display: none;
  margin: 12px 0;
  padding: 14px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

#ddtIframe {
  width: 100%;
  height: 680px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: white;
}

.btnChiudiDDT { float: right; font-size: 0.82em; padding: 5px 10px; margin-bottom: 8px; }
.ddtActions   { text-align: right; margin-top: 10px; }

/* ============================================================
   CHAT
   ============================================================ */
#chatToggle {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.86em;
  box-shadow: 0 2px 8px rgba(59,130,246,0.3);
  transition: all 0.2s;
  position: relative;
  white-space: nowrap;
}

#chatToggle:hover {
  box-shadow: 0 4px 14px rgba(59,130,246,0.45);
  transform: translateY(-1px);
}

.chat-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--c-danger);
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: bold;
  border: 2px solid var(--c-surface);
  animation: pulseBadge 2s infinite;
}

@keyframes pulseBadge {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.2); }
}

#chatContainer {
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: min(420px, calc(100vw - 24px));
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 1000;
  display: none;
  flex-direction: column;
  max-height: min(480px, calc(100vh - 80px));
}

#chatHeader {
  font-weight: bold;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--c-border);
  background: var(--btn-grad);
  color: white;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 0.9em;
}

#chatHeader button {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  padding: 3px 7px;
  cursor: pointer;
  border-radius: 4px;
}

#chatBox {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: var(--c-surface2);
  min-height: 240px;
  max-height: 300px;
}

#chatInputContainer {
  display: flex;
  padding: 8px;
  border-top: 1px solid var(--c-border);
  gap: 6px;
  background: var(--c-surface);
  border-radius: 0 0 var(--radius) var(--radius);
}

#chatInput {
  flex: 1;
  padding: 8px 10px;
  background: var(--c-surface2);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  font-size: 0.9em;
  color: var(--c-text);
  outline: none;
}

#chatInput:focus { border-color: var(--c-primary); }

#chatInputContainer button {
  padding: 8px 12px;
  background: var(--btn-grad);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.chatMsg {
  margin-bottom: 8px;
  padding: 7px 10px;
  border-radius: 10px;
  word-wrap: break-word;
  max-width: 85%;
  line-height: 1.4;
  font-size: 0.86em;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chatMsg.own {
  margin-left: auto;
  background: #ede9fe;
  color: #4c1d95;
  border: 1px solid #ddd6fe;
}

.chatMsg.other {
  background: var(--c-surface2);
  color: var(--c-text);
  border: 1px solid var(--c-border);
}

/* ============================================================
   FOTO MODAL
   ============================================================ */
#fotoModal {
  position: fixed;
  inset: 0;
  background: rgba(15,14,40,0.55);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1001;
  padding: 16px;
}

#fotoModalContent {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  padding: 20px 16px;
  border-radius: var(--radius);
  width: min(660px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}

#fotoModalContent h3 {
  margin-bottom: 12px;
  color: var(--c-text);
  border-bottom: 2px solid var(--c-border);
  padding-bottom: 8px;
  font-size: 1em;
}

#fotoInput {
  width: 100%;
  padding: 8px 10px;
  background: var(--c-surface2);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  margin-bottom: 10px;
  color: var(--c-text);
  font-size: 0.9em;
}

#fotoGallery {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0;
  min-height: 100px;
  border: 2px dashed var(--c-border);
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--c-surface2);
}

#fotoGallery img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid var(--c-border);
  transition: all 0.2s;
  cursor: pointer;
}

#fotoGallery img:hover {
  transform: scale(1.06);
  border-color: var(--c-primary);
}

/* ============================================================
   BARRA MODIFICA MULTIPLA
   ============================================================ */
.barra-modifica-multipla {
  display: none;
  position: sticky;
  top: 52px;
  background: var(--btn-grad);
  box-shadow: var(--shadow);
  z-index: 900;
  margin: 0 0 8px;
  border-radius: var(--radius);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4,0,0.2,1),
              padding 0.35s cubic-bezier(0.4,0,0.2,1);
}

.barra-modifica-multipla.attiva {
  display: block;
  max-height: 600px;
  padding: 10px 14px;
}

.barra-modifica-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 7px;
  border-bottom: 1px solid rgba(255,255,255,0.2);
  gap: 8px;
  flex-wrap: wrap;
}

.barra-modifica-header h3 {
  color: white;
  margin: 0;
  font-size: 1.05em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.contatore-badge {
  display: inline-block;
  background: var(--c-danger);
  color: white;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.8em;
  font-weight: bold;
  min-width: 26px;
  text-align: center;
  animation: pulseBadge 2s infinite;
}

.btnChiudiBarraMultipla {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  padding: 6px 12px;
  font-size: 0.85em;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}
.btnChiudiBarraMultipla:hover { background: rgba(255,255,255,0.28); }

.form-multiplo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 7px;
  margin-bottom: 8px;
}

.campo-multiplo { display: flex; flex-direction: column; gap: 3px; }

.campo-multiplo label {
  color: rgba(255,255,255,0.85);
  font-weight: 600;
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.campo-multiplo input,
.campo-multiplo select {
  padding: 7px 9px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  font-size: 0.88em;
  background: white;
  color: var(--c-text);
  transition: all 0.2s;
}

.campo-multiplo input:focus,
.campo-multiplo select:focus {
  outline: none;
  border-color: white;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.25);
}

.barra-modifica-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.2);
  flex-wrap: wrap;
}

.btnApplicaMultiplo {
  background: #22c55e;
  color: white;
  border: none;
  padding: 9px 24px;
  font-size: 0.92em;
  font-weight: bold;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(34,197,94,0.35);
  transition: all 0.2s;
}
.btnApplicaMultiplo:hover { background: #16a34a; transform: translateY(-1px); }

.ricerca-multipla-container {
  display: flex;
  gap: 5px;
  align-items: center;
  background: rgba(255,255,255,0.15);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.25);
}

.input-ricerca-multipla {
  width: 120px;
  padding: 6px 8px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 5px;
  font-size: 0.86em;
  font-weight: 600;
  text-transform: uppercase;
  background: white;
  color: var(--c-text);
  transition: all 0.2s;
}

.input-ricerca-multipla:focus { outline: none; border-color: white; }
.input-ricerca-multipla::placeholder { text-transform: none; font-weight: normal; color: var(--c-text-ph); }

.btnRicercaMultipla {
  padding: 6px 9px;
  min-width: auto;
  font-size: 0.86em;
  background: #22c55e;
  border-color: #16a34a;
}

.lista-selezionati {
  background: rgba(255,255,255,0.12);
  padding: 7px 10px;
  border-radius: 6px;
  margin-bottom: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 34px;
}

.lista-label { color: rgba(255,255,255,0.85); font-weight: bold; font-size: 0.82em; white-space: nowrap; }
.lista-numeri { color: #e9d5ff; font-weight: 600; font-size: 0.88em; flex: 1; line-height: 1.4; word-break: break-word; }

.cr-badge {
  display: inline-block;
  background: rgba(255,255,255,0.22);
  color: white;
  padding: 2px 7px;
  border-radius: 4px;
  margin: 2px;
  font-size: 0.8em;
  border: 1px solid rgba(255,255,255,0.3);
  cursor: pointer;
  transition: all 0.15s;
}
.cr-badge:hover { background: rgba(255,255,255,0.32); }
.cr-badge i { margin-left: 3px; font-size: 0.75em; opacity: 0.7; }
.cr-badge i:hover { opacity: 1; color: #fca5a5; }

/* ============================================================
   LOG VIEWER
   ============================================================ */
#logViewerModal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,14,40,0.6);
  z-index: 10000;
  overflow: auto;
  padding: 16px;
}

#logViewerContainer {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  margin: 0 auto;
  width: 100%;
  max-width: 1360px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
}

#logViewerHeader {
  background: var(--btn-grad);
  color: white;
  padding: 14px 18px;
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

#logViewerHeader h2 { margin: 0; font-size: 1.1em; color: white; }

#logViewerStats {
  background: rgba(255,255,255,0.15);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.8em;
}

#logViewerFilters {
  padding: 10px 14px;
  background: var(--c-surface2);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

#logViewerFilters label { font-weight: 600; font-size: 0.8em; color: var(--c-text-dim); }

#logViewerFilters select,
#logViewerFilters input {
  padding: 6px 10px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  font-size: 0.85em;
  color: var(--c-text);
}

#logViewerFilters button {
  padding: 6px 12px;
  background: var(--btn-grad);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.82em;
}

#logViewerContent { flex: 1; overflow-y: auto; padding: 14px; }

#logViewerTable { width: 100%; border-collapse: collapse; font-size: 0.8em; }

#logViewerTable thead {
  position: sticky;
  top: 0;
  background: var(--btn-grad);
  color: white;
  z-index: 10;
}

#logViewerTable th {
  padding: 9px 7px;
  text-align: left;
  font-weight: 700;
  border-bottom: 2px solid rgba(255,255,255,0.2);
  color: white;
}

#logViewerTable td {
  padding: 7px;
  border-bottom: 1px solid var(--c-border);
  color: var(--c-text);
  vertical-align: top;
}

#logViewerTable tbody tr:hover { background: var(--c-surface2); }

.log-row-error   { background: #fef2f2 !important; }
.log-row-alert   { background: #fff7ed !important; }
.log-row-success { background: #f0fdf4 !important; }

.log-azione { font-weight: bold; padding: 2px 6px; border-radius: 4px; display: inline-block; font-size: 0.78em; }
.log-azione-error   { background: #ef4444; color: white; }
.log-azione-alert   { background: #f97316; color: white; }
.log-azione-lock    { background: #3b82f6; color: white; }
.log-azione-sort    { background: #8b5cf6; color: white; }
.log-azione-insert  { background: #22c55e; color: white; }
.log-azione-update  { background: #eab308; color: #111; }
.log-azione-delete  { background: #ef4444; color: white; }
.log-azione-default { background: #6b7280; color: white; }

.log-dettagli { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; color: var(--c-primary); }
.log-dettagli:hover { text-decoration: underline; }
.log-dettagli-expanded {
  white-space: pre-wrap; word-break: break-all;
  background: var(--c-surface2); padding: 6px; border-radius: 4px;
  font-family: monospace; font-size: 0.76em; color: var(--c-text);
}

#logViewerFooter {
  padding: 10px 14px;
  background: var(--c-surface2);
  border-top: 1px solid var(--c-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btnLogViewer { padding: 8px 16px; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 0.85em; transition: all 0.2s; }
.btnLogViewer.primary   { background: #22c55e; color: white; }
.btnLogViewer.primary:hover  { background: #16a34a; }
.btnLogViewer.secondary { background: var(--btn-grad); color: white; }
.btnLogViewer.secondary:hover { background: var(--btn-grad-h); }
.btnLogViewer.danger    { background: #ef4444; color: white; }
.btnLogViewer.danger:hover { background: #dc2626; }

.log-empty, .log-loading { text-align: center; padding: 32px; color: var(--c-text-dim); font-size: 0.92em; }
.log-loading i { font-size: 1.8em; color: var(--c-primary); animation: spin 1s linear infinite; display: block; margin-bottom: 8px; }

/* ============================================================
   NOTIFICHE
   ============================================================ */
@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}
@keyframes slideUp {
  from { transform: translateY(0);     opacity: 1; }
  to   { transform: translateY(-100%); opacity: 0; }
}

/* ============================================================
   PERFORMANCE
   ============================================================ */
#tabellaDati { contain: layout style paint; }
#tabellaDati tbody { contain: layout style; }
.tabella-wrapper { transform: translateZ(0); }

@media (prefers-reduced-motion: reduce) {
  *, .barra-modifica-multipla, .riga-selezionata, .contatore-badge {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--c-surface2); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: #c4c9d8; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a0a8bb; }

/* ============================================================
   RESPONSIVE MOBILE
   ============================================================ */
@media (max-width: 1024px) {
  #logoLandolfo { max-width: 280px; padding: 0 14px; }
  #logoMorellato, #logoDestra { max-width: 130px; }
}

@media (max-width: 700px) {
  body { padding: 8px; }

  .intestazione { padding: 8px 10px; }
  .header { display: flex; flex-direction: column; align-items: center; gap: 6px; }
  #logoLandolfo { max-width: 200px; padding: 0 8px; grid-column: unset; grid-row: unset; }
  #logoMorellato, #logoDestra { max-width: 100px; grid-column: unset; grid-row: unset; }
  .contatti.contatti-sinistra, .contatti.contatti-centro { display: none; }
  .contatti.contatti-destra { font-size: 0.7em; grid-column: unset; }

  h2#numNeg { font-size: 1.15em; margin: 8px 0 6px; }

  .barraPulsanti { padding: 7px 10px; gap: 5px; border-radius: var(--radius-sm); }
  .barraPulsanti .sinistra, .barraPulsanti .destra { width: 100%; justify-content: flex-start; }
  .btnBase { padding: 7px 10px; font-size: 0.8em; }

  .ricerca-container { width: 100%; }
  .input-ricerca { flex: 1; width: auto; min-width: 0; font-size: 16px; }

  thead { top: 0; }
  .tabella-wrapper { border-radius: var(--radius-sm); margin-top: 6px; }

  #formOverlay { padding: 0; align-items: flex-end; }
  #formContainer {
    width: 100%;
    max-height: 92vh;
    border-radius: var(--radius) var(--radius) 0 0;
    margin: 0;
    padding: 16px 13px;
  }
  #formContainer label { font-size: 0.76em; }
  #formContainer select,
  #formContainer input,
  #formContainer textarea { font-size: 16px; padding: 10px; }

  #ddtIframe { height: 480px; }

  #chatContainer {
    bottom: 0; right: 0; left: 0; width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 68vh;
  }

  #fotoModal { padding: 0; align-items: flex-end; }
  #fotoModalContent { width: 100%; border-radius: var(--radius) var(--radius) 0 0; max-height: 84vh; }

  .barra-modifica-multipla { top: 0; border-radius: 0; margin: 0 0 6px; }
  .form-multiplo-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .barra-modifica-actions { gap: 6px; }
  .btnApplicaMultiplo { width: 100%; }
  .ricerca-multipla-container { width: 100%; }
  .input-ricerca-multipla { flex: 1; font-size: 16px; }
}

@media (max-width: 400px) {
  .form-multiplo-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   MINILOGO LOGIN BOX
   ============================================================ */
#minilogoLandolfo {
  display: block !important;
  width: min(220px, 75%) !important;
  height: auto !important;
  margin: 0 auto 12px;
}
