/* Design 89 - Custom Styling System with White/Light Theme, Logo Integration & Advanced Mobile Optimization */

:root {
  --primary-color: #F97316; /* Design 89 Orange */
  --primary-hover: #EA580C;
  --bg-color: #F8FAFC; /* Clean White / Slate Light Background */
  --card-bg: #FFFFFF;
  --text-main: #0F172A;
  --text-muted: #64748B;
  --border-color: #E2E8F0;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
}

/* LOGIN OVERLAY GATE */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #FFFFFF; /* Sfondo bianco opaco per nascondere completamente l'applicazione */
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  transition: opacity 0.3s ease;
}

.login-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.login-card {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
  animation: modalPop 0.25s ease-out;
}

.login-header {
  padding: 1.75rem 1.5rem 0.5rem 1.5rem;
  text-align: center;
}

/* HEADER NAVBAR */
.app-header {
  background: #FFFFFF;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 500;
  box-shadow: var(--shadow-sm);
}

.header-container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.header-logo-img {
  height: 42px;
  width: auto;
  display: block;
  object-fit: contain;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* ROLE BASED VISIBILITY */
body.role-squadra .tech-only {
  display: none !important;
}

/* MAIN CONTENT LAYOUT */
.main-content {
  max-width: 1300px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem 1.25rem;
}

/* DASHBOARD STATS BAR */
.dashboard-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--card-bg);
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: rgba(249, 115, 22, 0.12);
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.stat-info h4 {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
}

/* CANTIERI GRID SELECTION */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.section-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cantieri-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
}

.cantiere-card {
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.cantiere-card:hover, .cantiere-card:active {
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.cantiere-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
  gap: 0.5rem;
}

.cantiere-name {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.cantiere-details {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;

  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.cantiere-detail-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.progress-bar-container {
  margin-bottom: 0.75rem;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.progress-track {
  height: 8px;
  background: #E2E8F0;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary-color);
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* ACTIVE CANTIERE DETAILS & CONTROLS */
.controls-bar {
  background: #FFFFFF;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.filter-label {
  font-size: 0.825rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.select-control, .input-control {
  background: #F8FAFC;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  color: var(--text-main);
  font-size: 16px; /* Prevents iOS auto-zoom on mobile */
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease;
}

.select-control:focus, .input-control:focus {
  border-color: var(--primary-color);
  background: #FFFFFF;
}

/* INTERVENTI CHECKLIST CARDS - DYNAMIC COLOR SYSTEM */
.interventi-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.intervento-card {
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.5rem;
  border: 2px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Dynamic status background colors requested by user */
.intervento-card.card-stato-risolto {
  background-color: #ECFDF5; /* Soft Green */
  border-color: #10B981;
}

.intervento-card.card-stato-da_fare {
  background-color: #FEF2F2; /* Soft Red */
  border-color: #EF4444;
}

.zone-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.zone-area-badge {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--primary-color);
  background: rgba(249, 115, 22, 0.12);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
}

.zone-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.75rem;
}

.anomalia-box {
  background: #FFFFFF;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 0.75rem;
}

.anomalia-box h5 {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.anomalia-box p {
  font-size: 0.925rem;
  color: var(--text-main);
  font-weight: 500;
}

.intervento-box {
  background: #FEF08A; /* Light yellow background */
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid #EAB308; /* Yellow-600 border */
  margin-bottom: 0.75rem;
}

.intervento-box h5 {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: #854D0E; /* Yellow-800 text */
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.intervento-box p {
  font-size: 0.925rem;
  color: #713F12; /* Yellow-900 text */
  font-weight: 600;
}

.materiali-list {
  background: #FFFFFF;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-color);
  margin-bottom: 0.75rem;
}

.materiali-list h5 {
  font-size: 0.775rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.materiale-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #F1F5F9;
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-size: 0.825rem;
  margin-right: 0.4rem;
  margin-bottom: 0.4rem;
}

.materiale-code {
  font-family: monospace;
  font-weight: 700;
  color: var(--primary-color);
}

.notes-input {
  width: 100%;
  min-height: 70px;
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.65rem;
  font-family: inherit;
  font-size: 16px;
  color: var(--text-main);
  resize: vertical;
}

/* PHOTOS COMPARISON SIDE */
.photos-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.photo-box {
  display: flex;
  flex-direction: column;
}

.photo-label {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  text-align: center;
}

.photo-img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.photo-upload-placeholder {
  width: 100%;
  height: 140px;
  background: #FFFFFF;
  border: 2px dashed var(--primary-color);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--primary-color);
  cursor: pointer;
  font-size: 0.825rem;
  font-weight: 700;
  text-align: center;
  padding: 0.75rem;
  transition: background 0.2s ease;
}

.photo-upload-placeholder:active, .photo-upload-placeholder:hover {
  background: rgba(249, 115, 22, 0.08);
}

.photo-upload-input {
  display: none;
}

.btn-text {
  display: none;
}

@media (min-width: 769px) {
  .btn-text {
    display: inline;
  }
}

/* BUTTON SYSTEM */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.65rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary-color);
  color: #FFFFFF;
}

.btn-primary:hover, .btn-primary:active {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #FFFFFF;
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover, .btn-secondary:active {
  background: #F1F5F9;
}

.btn-success {
  background: #10B981;
  color: #FFFFFF;
}

.btn-success:hover, .btn-success:active {
  background: #059669;
}

.btn-sm {
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
}

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 800;
  border-radius: 20px;
  text-transform: uppercase;
}

.badge-risolto { background: #DCFCE7; color: #166534; }
.badge-da_fare { background: #FEF3C7; color: #92400E; }
.badge-pianificato { background: #DBEAFE; color: #1E40AF; }

/* MODALS */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 650px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: #F8FAFC;
}

.modal-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.modal-form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 2fr 80px;
  gap: 0.5rem;
}

/* RAPPORTINO PRINT & SIGNATURE CANVAS */
#printable-report {
  background: #FFFFFF;
  padding: 2.5rem;
  color: #0F172A;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
}

.report-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #0F172A;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.report-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  background: #F8FAFC;
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;

  font-size: 0.85rem;
}

.report-table th, .report-table td {
  border: 1px solid #CBD5E1;
  padding: 0.6rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

.report-table th {
  background: #F1F5F9;
  font-weight: 700;
  text-transform: uppercase;
}

.report-photo-thumb {
  width: 80px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
}

.report-signature-block {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid #E2E8F0;
}

.sig-box {
  background: #F8FAFC;
  padding: 1rem;
  border-radius: 6px;
  border: 1px solid #E2E8F0;
}

.signature-container {
  margin-top: 0.5rem;
}

.signature-canvas {
  width: 100%;
  height: 140px;
  background: #FFFFFF;
  border: 2px solid #CBD5E1;
  border-radius: 6px;
  touch-action: none;
  cursor: crosshair;
}

.signature-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sig-img-preview {
  max-height: 60px;
  width: auto;
  display: block;
}

/* PRINT MEDIA STYLES FOR RAPPORTINO */
@media print {
  body {
    background: #FFFFFF !important;
    color: #000000 !important;
  }

  /* Nasconde tutta l'interfaccia dell'applicazione tranne il modal del rapportino */
  body > *:not(#modal-rapportino) {
    display: none !important;
  }

  /* Rende statico e trasparente il backdrop del modal (evita flexbox e fixed in stampa) */
  #modal-rapportino {
    position: static !important;
    display: block !important;
    background: none !important;
    backdrop-filter: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Permette alla scheda del modal di espandersi in verticale in modo naturale su più pagine */
  #modal-rapportino .modal-card {
    position: static !important;
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    border: none !important;
    box-shadow: none !important;
    background: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Nasconde l'header e il footer del modal in stampa */
  #modal-rapportino .modal-header,
  #modal-rapportino .modal-footer {
    display: none !important;
  }

  /* Corpo del modal trasparente e fluido */
  #modal-rapportino .modal-body {
    background: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Nasconde la lavagna per disegnare la firma, tenendo solo il rapportino compilato */
  #modal-rapportino .modal-body > *:not(#rapportino-modal-content) {
    display: none !important;
  }

  /* Forza il contenitore del report a fluire come blocco statico paginabile */
  #printable-report {
    position: static !important;
    display: block !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Evita salti pagina spiacevoli a metà delle righe della tabella */
  .report-table tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  /* Forza la tabella classica a griglia per la stampa cartacea/PDF */
  #printable-report .report-table {
    display: table !important;
    width: 100% !important;
  }
  #printable-report .report-table thead {
    display: table-header-group !important;
  }
  #printable-report .report-table tbody {
    display: table-row-group !important;
  }
  #printable-report .report-table tr {
    display: table-row !important;
    border: none !important;
    background: none !important;
    padding: 0 !important;
  }
  #printable-report .report-table th, 
  #printable-report .report-table td {
    display: table-cell !important;
    border: 1px solid #CBD5E1 !important;
    padding: 0.6rem 0.75rem !important;
  }
  #printable-report .report-table td::before {
    display: none !important;
  }
}

/* ==========================================================================
   ADVANCED MOBILE RESPONSIVE STYLES (OPTIMIZED FOR SQUADRA DI MONTAGGIO)
   ========================================================================== */
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden;
    width: 100%;
  }

  .header-container {
    padding: 0.6rem 0.75rem;
    width: 100%;
    max-width: 100vw;
  }

  .header-logo-img {
    height: 30px;
  }

  .header-actions {
    gap: 0.35rem;
  }

  .header-actions .btn {
    padding: 0.4rem 0.5rem;
    font-size: 0.8rem;
    gap: 0;
  }

  .main-content {
    padding: 1rem 0.65rem 2.5rem 0.65rem;
    width: 100%;
    max-width: 100vw;
  }

  /* Statistiche in griglia compatta 2x2 per smartphone */
  .dashboard-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
    margin-bottom: 1.25rem;
  }

  .stat-card {
    padding: 0.75rem;
    flex-direction: column;
    text-align: center;
    gap: 0.4rem;
    border-radius: var(--radius-md);
  }

  .stat-icon {
    width: 36px;
    height: 36px;
    font-size: 1rem;
    margin: 0 auto;
  }

  .stat-info h4 {
    font-size: 0.65rem;
    margin-bottom: 0.15rem;
  }

  .stat-value {
    font-size: 1.2rem;
  }

  /* Bottoni selezione cantieri a larghezza intera su mobile */
  .tab-toggle-group {
    display: flex;
    width: 100%;
    gap: 0.5rem;
    margin-top: 0.5rem;
  }

  .tab-toggle-group .btn {
    flex: 1;
    font-size: 0.8rem;
    padding: 0.55rem 0.35rem;
    justify-content: center;
    white-space: normal;
    text-align: center;
  }

  .section-title {
    font-size: 1.2rem;
  }

  .cantieri-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
    width: 100%;
  }

  .cantiere-card {
    padding: 1.15rem 1rem;
    width: 100%;
  }

  .cantiere-name {
    font-size: 1.1rem;
  }

  .active-cantiere-header-card {
    padding: 1rem !important;
  }

  .back-to-list-btn {
    width: 100%;
    margin-bottom: 0.75rem;
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    justify-content: flex-start;
  }

  .btn-rapportino-mobile {
    width: 100%;
    justify-content: center;
    font-size: 0.95rem;
    padding: 0.7rem 1rem;
  }

  .cantiere-action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    width: 100%;
    margin-top: 0.75rem;
  }

  .controls-bar {
    padding: 0.85rem;
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }

  .filter-item {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .search-filter-group {
    max-width: 100% !important;
  }

  .intervento-card {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    padding: 1rem;
  }

  .photos-comparison {
    gap: 0.6rem;
  }

  .photo-img, .photo-upload-placeholder {
    height: 135px;
  }

  .modal-form-grid, .modal-form-grid-3 {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .report-info-grid, .report-signature-block {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .signatures-editing-grid {
    grid-template-columns: 1fr !important;
  }

  /* Adattamento visualizzazione rapportino su schermo cellulare */
  #rapportino-modal-content {
    background: #475569;
    padding: 0.5rem;
    border-radius: 8px;
  }

  #printable-report {
    padding: 1.25rem 1rem !important;
  }

  #printable-report .report-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  #printable-report .report-header .report-title-box {
    text-align: left;
  }

  #printable-report .report-info-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    padding: 0.75rem;
  }

  /* Trasforma le tabelle in schede a blocchi leggibili per cellulare */
  #printable-report .report-table,
  #printable-report .report-table thead,
  #printable-report .report-table tbody,
  #printable-report .report-table th,
  #printable-report .report-table td,
  #printable-report .report-table tr {
    display: block !important;
    width: 100% !important;
  }

  #printable-report .report-table thead {
    display: none !important;
  }

  #printable-report .report-table tr {
    border: 1px solid #CBD5E1 !important;
    border-radius: 8px !important;
    margin-bottom: 1rem !important;
    padding: 0.75rem !important;
    background: #F8FAFC !important;
  }

  #printable-report .report-table td {
    border: none !important;
    padding: 0.4rem 0 !important;
    position: relative !important;
  }

  #printable-report .report-table td:not(:last-child) {
    border-bottom: 1px dashed #E2E8F0 !important;
  }

  /* Etichette per identificare le colonne */
  #printable-report .report-table td::before {
    content: attr(data-label);
    display: block;
    font-weight: 700;
    font-size: 0.75rem;
    color: #64748B;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
  }

  #printable-report .report-photo-thumb {
    width: 120px;
    height: 90px;
  }

  #printable-report .report-signature-block {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-top: 1.5rem;
  }
}

/* Row of dynamic materials input in modals */
.material-input-row {
  display: grid;
  grid-template-columns: 1fr 90px 45px;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: center;
}

/* ==========================================================================
   STILE SPECIALE PER TABELLA ANTEPRIMA IMPORTAZIONE PDF
   ========================================================================== */

#view-import-preview {
  margin-top: 1rem;
}

#view-import-preview .report-table {
  border: 1px solid #94A3B8; /* Bordo esterno scuro e marcato */
  box-shadow: var(--shadow-sm);
  border-collapse: separate; /* Permette bordi esterni e arrotondamenti */
  border-spacing: 0;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

#view-import-preview .report-table th,
#view-import-preview .report-table td {
  border: none;
  border-bottom: 1px solid #CBD5E1;
  border-right: 1px solid #CBD5E1;
  padding: 0.75rem;
  vertical-align: middle;
}

/* Rimuove l'ultimo bordo a destra per ogni colonna */
#view-import-preview .report-table th:last-child,
#view-import-preview .report-table td:last-child {
  border-right: none;
}

/* Rimuove l'ultimo bordo in basso */
#view-import-preview .report-table tr:last-child td {
  border-bottom: none;
}

#view-import-preview .report-table th {
  background: #E2E8F0; /* Sfondo intestazione più evidente */
  color: #1E293B;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  border-bottom: 2px solid #94A3B8;
  text-align: center;
}

#view-import-preview .report-table td {
  background: #FFFFFF;
}

/* Righe alternate per favorire la lettura orizzontale */
#view-import-preview .report-table tr:nth-child(even) td {
  background: #F8FAFC;
}

/* Forziamo un bordo e un contrasto maggiore sui campi editabili della tabella */
#view-import-preview .select-control,
#view-import-preview .input-control,
#view-import-preview .notes-input {
  background: #FFFFFF !important;
  border: 1.5px solid #94A3B8 !important; /* Bordo più marcato e visibile */
  border-radius: 6px !important;
  padding: 0.5rem 0.65rem !important;
  color: #0F172A !important;
  font-size: 0.875rem !important;
  font-family: inherit !important;
  width: 100% !important;
  outline: none !important;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05) !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
}

#view-import-preview .notes-input {
  resize: vertical;
  min-height: 60px;
}

#view-import-preview .select-control:focus,
#view-import-preview .input-control:focus,
#view-import-preview .notes-input:focus {
  border-color: var(--primary-color) !important;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2), inset 0 1px 2px rgba(0, 0, 0, 0.05) !important;
  background: #FFFFFF !important;
}

/* Stile per i badge all'interno della tabella */
#view-import-preview .badge-bv {
  background-color: #DBEAFE;
  color: #1E40AF;
  border: 1px solid #BFDBFE;
}

#view-import-preview .badge-d89 {
  background-color: #FEE2E2;
  color: #991B1B;
  border: 1px solid #FECACA;
}

#view-import-preview .badge {
  background-color: #F1F5F9;
  color: #475569;
  border: 1px solid #E2E8F0;
}

