.perizia-details-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 70;
  display: none;
}

.perizia-details-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(920px, 96vw);
  height: 90vh;
  max-height: 90vh;
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  z-index: 71;
  padding: 16px 18px 18px;
  overflow-y: auto;
}

#btnPeriziaDetailsClose {
  display: none;
}

.perizia-details-popup #btnPeriziaDetailsClose {
  display: inline-flex;
}

.management-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.management-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.management-popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 70;
}

.management-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(860px, 92vw);
  height: 86vh;
  max-height: 86vh;
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  z-index: 71;
  display: flex;
  flex-direction: column;
  padding: 16px 18px 18px;
  overflow: hidden;
}

.ass-filters-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 6px;
}

.ass-filters-grid input,
.ass-filters-grid select {
  padding: 5px 6px;
  font-size: 13px;
}

.ass-filters-actions {
  grid-column: span 3;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.manual-assign-popup {
  width: min(520px, 92vw);
  height: auto;
  max-height: 80vh;
  overflow: hidden;
}

.manual-assign-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.manual-assign-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  background: #fafafa;
  font-size: 13px;
}

.manual-assign-item label {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
}

.management-popup.perizie-assign-popup {
  width: min(1320px, 96vw);
}

.management-popup.sopralluoghi-cost-popup {
  width: fit-content;
  height: fit-content;
  max-width: 90vw;
  max-height: 90vh;
  overflow: visible;
  padding: 14px 16px;
  transform: translate(-50%, -50%) scale(1.1);
  transform-origin: center;
}

.management-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.management-popup-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.management-popup-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: transparent;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-muted);
}

.management-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin-bottom: 8px;
}

.management-tab {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.management-tab:hover {
  background: var(--border);
}

.management-tab.active {
  background: var(--interactive-light);
  color: var(--interactive);
  border-color: var(--interactive);
  font-weight: 600;
}

.management-tab-panel {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

.management-tab-panel.active {
  display: block;
}

.management-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.management-sheet-title {
  font-weight: 600;
  color: var(--text-main);
}

.management-sheet-actions {
  display: flex;
  gap: 6px;
}

.management-search {
  display: flex;
  margin-bottom: 8px;
}

.management-table-group td {
  background: var(--surface-alt);
  font-weight: 600;
  color: var(--text-main);
}

.calendar-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.calendar-btn:hover {
  background: var(--surface-alt);
}

.calendar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: none;
}

.calendar-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, 92vw);
  max-height: 80vh;
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  z-index: 51;
  display: none;
  padding: 14px 16px 16px;
  overflow: hidden;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.calendar-nav-btn {
  border: 1px solid var(--border);
  background: #ffffff;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.calendar-cell {
  min-height: 70px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 6px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calendar-cell .day-label {
  font-weight: 600;
  color: #111827;
}

.calendar-item {
  font-size: 11px;
  padding: 2px 4px;
  border-radius: 4px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
}


label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="tel"],
textarea,
select {
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-main);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

gmp-place-autocomplete {
  width: 100%;
  display: block;
  position: relative;
  z-index: 5;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-sizing: border-box;
}

gmp-place-autocomplete::part(input) {
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  border: none;
  font-size: 13px;
  box-sizing: border-box;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  line-height: 1.3;
  box-shadow: none;
  outline: none;
}

gmp-place-autocomplete::part(input)::placeholder {
  color: var(--text-muted);
}

gmp-place-autocomplete::part(listbox) {
  z-index: 10;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
}

textarea {
  resize: vertical;
  min-height: 50px;
}

.row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.row > div {
  flex: 1;
  min-width: 0;
}

/* Evita l'auto-allargamento del campo indirizzo durante la digitazione */
#addressSearchSection #addressSearch,
#addressSearchSection gmp-place-autocomplete#addressSearch {
  width: 100% !important;
  max-width: 100%;
  box-sizing: border-box;
}

#addressSearchSection gmp-place-autocomplete#addressSearch::part(input) {
  width: 100% !important;
  min-width: 0;
  box-sizing: border-box;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-field label {
  flex: 1;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inline-field input {
  flex: 0 0 70px;
  min-width: 0;
}

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  padding: 7px 16px;
  font-size: 13px;
  cursor: pointer;
  background: var(--interactive);
  color: #ffffff;
  font-weight: 500;
  box-shadow: var(--shadow-xs);
  transition:
    background 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.1s ease;
}

.btn:hover:not(:disabled) {
  background: #1d4ed8;
  box-shadow: var(--shadow-sm);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: none;
}

.btn.sec {
  background: var(--surface);
  color: var(--text-main);
  border-color: var(--border);
  box-shadow: none;
}

.btn.sec:hover:not(:disabled) {
  background: var(--surface-alt);
  box-shadow: var(--shadow-xs);
}

.btn.sec:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
}

.btn.copied {
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.35);
}

.btn-compact {
  padding: 4px 10px;
  font-size: 12px;
}

.export-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.export-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.export-action-btn {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  border: 1px solid var(--interactive);
  background: var(--surface);
  color: var(--interactive);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  position: relative;
  transition:
    background 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.05s ease;
}

.export-action-btn::before {
  content: "";
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 8px solid var(--interactive);
  margin-left: 2px;
}

.export-action-btn:hover:not(:disabled) {
  background: var(--interactive-light);
  box-shadow: var(--shadow-xs);
}

.export-action-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.export-action-btn:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
}

.export-action-text {
  font-size: 13px;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.export-stop-btn {
  display: none;
  border: 1px solid #b91c1c;
  color: #b91c1c;
  background: #ffffff;
  border-radius: 999px;
  font-size: 12px;
  padding: 2px 10px;
  cursor: pointer;
  line-height: 1.2;
}

.export-stop-btn:hover:not(:disabled) {
  background: #fee2e2;
}

.export-stop-btn:disabled {
  opacity: 0.6;
  cursor: default;
}
