:root{--green:#1f7a4d;--dark:#173b2b;--light:#f5f7f2;--line:#d7e2d6;--grey:#f1f5ef}
*{box-sizing:border-box}
body{margin:0;font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;background:var(--light);color:#18251f}
header{background:linear-gradient(135deg,var(--green),#0e9a73);color:white;padding:18px;display:flex;align-items:center;justify-content:space-between;gap:12px}
h1{margin:0;font-size:28px} header p{margin:4px 0 0}
#onlineStatus{background:rgba(255,255,255,.18);padding:8px 12px;border-radius:999px;font-size:13px}
main{padding:16px;max-width:1150px;margin:auto}
.page{display:none}.page.active{display:block}
.panel,.homeCard{background:white;border:1px solid var(--line);border-radius:18px;padding:18px;box-shadow:0 8px 22px rgba(0,0,0,.05)}
.homeCard{max-width:720px;margin:42px auto;text-align:center;padding:30px}
.homeCard h2{font-size:34px;margin:0 0 8px}
.projectHeader{display:flex;justify-content:space-between;gap:12px;align-items:flex-start;flex-wrap:wrap}
.tabs{display:flex;overflow-x:auto;gap:6px;padding:10px;background:white;border:1px solid var(--line);border-radius:18px;margin-bottom:14px}
.tabs button{border:0;background:#e9f1e8;color:var(--dark);padding:10px 14px;border-radius:12px;font-weight:700;white-space:nowrap}
.tabs button.active{background:var(--green);color:white}
.tab{display:none}.tab.active{display:block}
.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:12px}
label{display:block;font-weight:700;margin:10px 0}
input,select,textarea{width:100%;margin-top:6px;padding:11px;border:1px solid #cdd8cc;border-radius:10px;font:inherit;background:white}
textarea{min-height:105px;resize:vertical}
button{cursor:pointer;border:0;border-radius:12px;padding:12px 15px;font-weight:800;background:var(--green);color:white}
.actions{display:flex;flex-wrap:wrap;gap:10px;margin:14px 0}.center{justify-content:center}
.treeList{display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:12px;margin-top:12px}
.treeCard{border:1px solid var(--line);background:#fbfdfb;border-radius:14px;padding:14px}
.treeCard h4{margin:0 0 6px;color:var(--dark)}
.treeCard p{margin:2px 0;color:#536057}
.photoCard{border:1px solid var(--line);border-radius:12px;overflow:hidden;background:#fafafa}
#photos{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px;margin-top:12px}
.photoCard img{width:100%;height:130px;object-fit:cover;display:block}
.photoCard input{border:0;border-top:1px solid var(--line);border-radius:0}
pre{white-space:pre-wrap;background:var(--grey);padding:12px;border-radius:12px}
footer{padding:12px 16px;display:flex;justify-content:space-between;gap:10px;color:#5a665e}
@media(max-width:600px){header{align-items:flex-start;flex-direction:column}main{padding:10px}.homeCard{margin:20px auto;padding:20px}.homeCard h2{font-size:28px}.panel{padding:14px;border-radius:14px}}

.hint{background:#eff8f1;border-left:4px solid var(--green);padding:10px;border-radius:10px;color:#355144}
.mapBox{height:430px;border:1px solid var(--line);border-radius:16px;overflow:hidden;margin:12px 0;background:#e8eee7}
.leaflet-container{font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif}
@media(max-width:600px){.mapBox{height:360px}}

.smallHint{font-size:14px;margin-top:8px}
.manualModeActive{background:#fff7ed!important;border-left-color:#f97316!important}

#btnBackProjectFromTabs{
  background:#173b2b;
  color:white;
}
.treeCard .dangerButton{
  background:#b91c1c;
}

.leaflet-control-layers{
  border-radius:12px!important;
  box-shadow:0 8px 22px rgba(0,0,0,.18)!important;
}
.leaflet-control-layers-expanded{
  max-height:330px;
  overflow:auto;
  font-size:13px;
}

#onlineStatus.onlineStatusOnline{
  background:#16a34a!important;
  color:white!important;
}
#onlineStatus.onlineStatusOffline{
  background:#dc2626!important;
  color:white!important;
}
button[id*="Back"],
#btnBackProjectFromTabs{
  background:#173b2b!important;
  color:white!important;
}
.leaflet-control-layers{
  border-radius:12px!important;
  box-shadow:0 8px 22px rgba(0,0,0,.18)!important;
}
.leaflet-control-layers-expanded{
  max-height:340px;
  overflow:auto;
  font-size:13px;
}

.leaflet-control-layers{border-radius:12px!important;box-shadow:0 8px 22px rgba(0,0,0,.18)!important}
.leaflet-control-layers-expanded{max-height:340px;overflow:auto;font-size:13px}

.fileButton{
  cursor:pointer;
  border:0;
  border-radius:12px;
  padding:12px 15px;
  font-weight:800;
  background:var(--green);
  color:white;
  display:inline-block;
  margin:0;
}
.photoFullTreeBox{
  margin-top:18px;
  padding:14px;
  border:1px solid var(--line);
  border-radius:16px;
  background:#fbfdfb;
}
.fullTreePhotoPreview{ margin-top:12px; }
.fullTreePhotoPreview p{ color:#5a665e; }
.fullTreePhotoCard img{
  max-width:100%;
  max-height:520px;
  object-fit:contain;
  border:1px solid var(--line);
  border-radius:14px;
  background:white;
  display:block;
}
.fullTreePhotoCard p{
  margin:8px 0 0;
  font-size:13px;
}

.checkboxLabel{
  display:flex;
  align-items:center;
  gap:10px;
  font-weight:800;
}
.checkboxLabel input{
  width:auto;
  margin:0;
}
.conditionalBox{
  grid-column:1 / -1;
  border:1px solid var(--line);
  border-radius:16px;
  padding:14px;
  background:#fbfdfb;
  margin:6px 0;
}
.conditionalBox h3{
  margin:0 0 8px;
}
.hiddenBox{
  display:none!important;
}

/* V20 - Condizioni salute a tutta larghezza */
label:has(#condizioniSalute){
  grid-column: 1 / -1;
}
#condizioniSalute{
  width:100%;
}

/* V29 - Scheda difetti strutturata */
.defectsRoot{
  display:flex;
  flex-direction:column;
  gap:18px;
  margin:14px 0 18px;
}
.defectZoneCard{
  border:1px solid var(--line);
  border-radius:18px;
  background:#fbfdfb;
  padding:16px;
}
.defectZoneHeader h3{
  margin:0 0 12px;
  color:var(--green);
}
.defectAddRow{
  display:grid;
  grid-template-columns:1fr auto;
  gap:12px;
  align-items:end;
  margin-top:10px;
}
.defectEntries{
  margin-top:14px;
  display:flex;
  flex-direction:column;
  gap:12px;
}
.emptyDefects{
  color:#667;
  font-size:14px;
  margin:6px 0 0;
}
.defectEntry{
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px;
  background:white;
}
.defectEntryTitle{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  margin-bottom:10px;
}
.defectEntryTitle strong{
  color:#24352c;
}
.defectEntryGrid{
  grid-template-columns:160px 1fr 160px;
  align-items:end;
}
.defectPhotoButton{
  text-align:center;
}
.defectPhotoPreview{
  margin-top:10px;
}
.defectPhotoPreview p{
  color:#667;
  font-size:13px;
  margin:0;
}
.defectPhotoCard{
  display:flex;
  align-items:flex-start;
  gap:12px;
}
.defectPhotoCard img{
  max-width:220px;
  max-height:180px;
  object-fit:contain;
  border:1px solid var(--line);
  border-radius:12px;
  background:#fff;
}
.btnRemoveDefect,
.btnRemoveDefectPhoto{
  background:#b91c1c!important;
  color:white!important;
}
@media(max-width:760px){
  .defectAddRow,
  .defectEntryGrid{
    grid-template-columns:1fr;
  }
  .defectPhotoCard{
    flex-direction:column;
  }
}

/* V31 - Import F3D Tomografia */
.instrumentBox{
  margin-bottom:18px;
  padding:16px;
  border:1px solid var(--line);
  border-radius:18px;
  background:#fbfdfb;
}
.instrumentBox h3{
  margin:0 0 8px;
  color:var(--green);
}
.f3dSummary{
  margin-top:12px;
}
.f3dCard{
  border:1px solid var(--line);
  background:white;
  border-radius:14px;
  padding:12px;
}
.f3dCard h4{
  margin:0 0 10px;
}
.f3dTable{
  width:100%;
  border-collapse:collapse;
  margin-top:10px;
  font-size:13px;
}
.f3dTable th,
.f3dTable td{
  border:1px solid var(--line);
  padding:6px;
  text-align:left;
}
.f3dTable th{
  background:#eef6f0;
}

/* V32 - Resistograph e allegati tomografia */
.rgpSummary{
  margin-top:12px;
}
.rgpCard{
  border:1px solid var(--line);
  background:white;
  border-radius:14px;
  padding:12px;
}
.rgpCard h4{
  margin:0 0 10px;
}
.instrumentPreview,
.instrumentPreviewGrid{
  margin-top:12px;
}
.instrumentPreviewGrid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:14px;
}
.instrumentAttachmentCard,
.instrumentImageCard{
  border:1px solid var(--line);
  border-radius:14px;
  background:white;
  padding:12px;
}
.instrumentImageCard img{
  width:100%;
  max-height:420px;
  object-fit:contain;
  border:1px solid var(--line);
  border-radius:12px;
  background:#fff;
}
.instrumentImageCard p{
  font-size:13px;
  color:#667;
}
.instrumentTable{
  width:100%;
  border-collapse:collapse;
  margin-top:10px;
  font-size:13px;
}
.instrumentTable th,
.instrumentTable td{
  border:1px solid var(--line);
  padding:6px;
  text-align:left;
}
.instrumentTable th{
  background:#eef6f0;
}
@media(max-width:760px){
  .instrumentPreviewGrid{
    grid-template-columns:1fr;
  }
}

/* V33 - Strumentali multipli e modelli 3D */
.instrumentList{
  display:flex;
  flex-direction:column;
  gap:14px;
  margin-top:12px;
}
.instrumentCard{
  border:1px solid var(--line);
  border-radius:16px;
  background:white;
  padding:14px;
}
.instrumentCardHeader{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:center;
  margin-bottom:12px;
}
.instrumentCardHeader h4{
  margin:0;
  color:var(--green);
}
.instrumentMiniSummary{
  border:1px solid var(--line);
  background:#f7fbf8;
  border-radius:12px;
  padding:10px;
  margin-top:10px;
  font-size:14px;
}
.pdfInlinePreview{
  width:100%;
  height:360px;
  border:1px solid var(--line);
  border-radius:12px;
  background:white;
}
.btnRemoveInstrument,
.btnRemoveInstrumentAttachment{
  background:#b91c1c!important;
  color:white!important;
}
.modelSummary{
  margin-top:10px;
}
.instrumentCard textarea{
  min-height:90px;
}
@media(max-width:760px){
  .instrumentCardHeader{
    flex-direction:column;
    align-items:flex-start;
  }
  .pdfInlinePreview{
    height:260px;
  }
}

/* V34 - miglioramenti strumentali */
.rgpOrientamentoAuto[readonly]{
  background:#eef6f0;
  font-weight:800;
}
.tomoSchemaPreview .instrumentImageCard img{
  max-height:520px;
}

/* V35 - Schema rilievi strumentali */
.instrumentalSchemaCard img{
  width:100%;
  max-height:780px;
  object-fit:contain;
}
#instrumentalSchemaPreview{
  margin-top:14px;
}

/* V36 - verifica caricamenti */
.instrumentLoading{
  padding:8px 10px;
  border-radius:10px;
  background:#eef6f0;
  color:#166534;
  font-weight:700;
}
.instrumentError{
  padding:8px 10px;
  border-radius:10px;
  background:#fee2e2;
  color:#991b1b;
  font-weight:700;
}

/* V37 - Import Excel con mappatura */
.excelMappingPanel{margin-top:16px;}
.excelMappingRows{display:flex;flex-direction:column;gap:8px;margin:12px 0;}
.excelMappingRows h4{margin:16px 0 4px;color:var(--green);}
.excelMappingRow{display:grid;grid-template-columns:1fr 1.2fr;gap:12px;align-items:center;border:1px solid var(--line);border-radius:12px;padding:10px;background:#fff;}
.excelAppField{font-weight:800;color:#26352d;}
.excelPreviewBox{margin:14px 0;}
.excelPreviewCard{border:1px solid var(--line);border-radius:14px;background:#fbfdfb;padding:12px;}
.excelPreviewCard pre{white-space:pre-wrap;max-height:320px;overflow:auto;background:#fff;border:1px solid var(--line);border-radius:10px;padding:10px;}
@media(max-width:760px){.excelMappingRow{grid-template-columns:1fr;}}

/* V39 - mappatura Excel grafica */
.excelGraphicHelp{
  border:1px solid var(--line);
  background:#eef6f0;
  color:#1f3d2c;
  border-radius:14px;
  padding:12px;
  margin:12px 0;
}
.excelColumnCards{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(280px, 1fr));
  gap:14px;
  margin:14px 0;
}
.excelColumnCard{
  border:1px solid var(--line);
  border-radius:16px;
  background:white;
  padding:14px;
  box-shadow:0 4px 14px rgba(0,0,0,.04);
}
.excelColumnTitle{
  display:flex;
  align-items:center;
  gap:10px;
  margin-bottom:10px;
}
.excelColumnLetter{
  min-width:38px;
  height:38px;
  border-radius:12px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:var(--green);
  color:white;
  font-weight:900;
}
.excelColumnSample{
  display:flex;
  flex-direction:column;
  gap:4px;
  min-height:72px;
  margin:8px 0 12px;
  padding:8px;
  border-radius:12px;
  background:#f7faf8;
  font-size:13px;
  color:#45534a;
}
.excelColumnSample span{
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.excelColumnCard select{
  width:100%;
}

/* V40 - pulsanti navigazione coerenti */
#btnHomeFromForm,
#btnHomeFromSaved,
#btnHomeFromExcel,
#btnHomeFromTree,
#btnBackHomeFromProject,
#btnBackHomeFromSaved,
#btnExcelBackSaved,
#btnBackHomeFromForm,
#btnBackProject{
  background:#173b2b!important;
  color:white!important;
}

/* V41 - sync, ricerca, importa difetti */
.projectSyncPanel{
  margin-top:16px;
}
.syncStatusCard{
  border:1px solid var(--line);
  border-radius:16px;
  padding:12px;
  background:white;
}
.syncPending{background:#fff7ed;border-color:#fed7aa}
.syncOk{background:#ecfdf5;border-color:#bbf7d0}
.syncLocal{background:#eff6ff;border-color:#bfdbfe}
.compactFileButton{
  font-size:14px;
  padding:10px 12px;
}
.searchResults{
  display:flex;
  flex-direction:column;
  gap:12px;
  margin-top:18px;
}
.searchSummary{
  padding:10px 12px;
  border-radius:14px;
  background:#eef6f0;
  border:1px solid var(--line);
}
.searchResultCard{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:center;
  border:1px solid var(--line);
  border-radius:16px;
  background:white;
  padding:14px;
}
.searchResultCard small{
  color:#53635a;
}
.defectImportBox{
  border:1px solid var(--line);
  border-radius:16px;
  background:#fbfdfb;
  padding:14px;
  margin-bottom:14px;
}
.defectImportBox h3{
  margin-top:0;
  color:var(--green);
}
.defectImportBox select{
  min-width:260px;
}
@media(max-width:760px){
  .searchResultCard{
    flex-direction:column;
    align-items:flex-start;
  }
  .defectImportBox .actions{
    flex-direction:column;
    align-items:stretch;
  }
}

/* V42 - Login */
.loginCard{
  max-width:520px;
  margin:40px auto;
}
.loginCard label{
  display:block;
  text-align:left;
  margin:14px 0;
}
.loginCard input[type="email"],
.loginCard input[type="password"]{
  width:100%;
}
.rememberLoginLabel{
  justify-content:flex-start;
}
.devLoginHelp{
  text-align:left;
  margin-top:14px;
  color:#53635a;
}
.headerStatus{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}
#loggedUserBadge{
  font-size:13px;
  background:#eef6f0;
  color:#173b2b;
  border-radius:999px;
  padding:6px 10px;
  font-weight:700;
}
.logoutButton{
  border:0;
  border-radius:999px;
  padding:7px 11px;
  background:#173b2b;
  color:white;
  font-weight:800;
  cursor:pointer;
}

/* Arboris V45 server */
#shareProjectPanel label{
  margin-top:10px;
}
#shareProjectPanel input{
  max-width:420px;
}
