:root {
  --green: #1f7a3a;
  --green-2: #155a2b;
  --line: #d6e3da;
  --text: #1a2a20;
  --bg: #f3f8f5;
  --card: #ffffff;
  --danger: #a33232;
  --info-bg: #f2f7ff;
  --info-line: #cdddff;
  --info-text: #1f427c;
  --success-bg: #f5fbf7;
  --success-line: #d5e7da;
  --success-text: #19472a;
  --warning-bg: #fff8e8;
  --warning-line: #f0ddb1;
  --warning-text: #7b5b00;
  --error-bg: #fff3f3;
  --error-line: #efc6c6;
  --error-text: #8a1c1c;
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none;
}

body.app-appezzamenti-page {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.05);
}

.header {
  padding: 16px;
  display: grid;
  gap: 10px;
}

.title {
  margin: 0;
  color: var(--green);
}

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

.badge {
  border: 1px solid #d7e6db;
  background: #f8fcf9;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.9rem;
}

.btn {
  border: 1px solid var(--green);
  background: var(--green);
  color: #fff;
  border-radius: 10px;
  padding: 9px 12px;
  font-weight: 700;
  cursor: pointer;
}

.btn:hover {
  background: var(--green-2);
  border-color: var(--green-2);
}

.btn.secondary {
  background: #fff;
  color: var(--green);
}

.btn.secondary:hover {
  color: #fff;
}

.btn.danger {
  border-color: var(--danger);
  background: var(--danger);
}

.link-btn {
  text-decoration: none;
  line-height: 1.2;
}

.status {
  border: 1px solid var(--success-line);
  background: var(--success-bg);
  color: var(--success-text);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 0.88rem;
  margin-top: 4px;
}

.status.info,
.status.loading {
  border-color: var(--info-line);
  background: var(--info-bg);
  color: var(--info-text);
}

.status.warning {
  border-color: var(--warning-line);
  background: var(--warning-bg);
  color: var(--warning-text);
}

.status.error {
  border-color: var(--error-line);
  background: var(--error-bg);
  color: var(--error-text);
}

.status.success {
  border-color: var(--success-line);
  background: var(--success-bg);
  color: var(--success-text);
}

.content {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 14px;
  min-height: 76vh;
  align-items: start;
}

.sidebar {
  padding: 14px;
  padding-bottom: 150px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  overflow-x: hidden;
  scroll-padding-bottom: 150px;
}

.sidebar h2 {
  margin: 0;
  font-size: 1.02rem;
  color: #244532;
}

.search,
select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #c8d8cd;
  border-radius: 10px;
  font: inherit;
  background: #fff;
}

.field-sort-control {
  display: grid;
  gap: 6px;
}

.field-sort-control label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #244532;
}

.list {
  border: 1px solid #d8e4db;
  border-radius: 10px;
  overflow-y: visible;
  overflow-x: hidden;
  min-height: 220px;
  background: #fff;
}

.list-loading {
  border: 1px dashed #cdddff;
  background: #f8fbff;
  color: var(--info-text);
  border-radius: 10px;
  padding: 10px;
  font-size: 0.9rem;
}

.list-loading.hidden {
  display: none;
}

.item {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 10px;
  border-bottom: 1px solid #eff5f1;
  cursor: pointer;
  display: grid;
  gap: 2px;
  font: inherit;
}

.field-group-heading {
  background: #f1f7f3;
  border-bottom: 1px solid #d8e4db;
  color: #244532;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 8px 10px;
  text-transform: uppercase;
}

.item:hover {
  background: #f6fbf8;
}

.item.active {
  background: #e8f4ec;
}

.item-name {
  font-weight: 700;
}

.item-meta {
  font-size: 0.82rem;
  opacity: 0.82;
}

.item-meta.strong {
  color: #244532;
  font-weight: 700;
  opacity: 1;
}

.item-groups,
.groups-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.group-chip {
  border: 1px solid #cfe1d4;
  background: #f2f8f4;
  border-radius: 8px;
  color: #244532;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 3px 6px;
}

.empty-list {
  padding: 10px;
  font-size: 0.9rem;
  opacity: 0.75;
}

.form {
  border: 1px solid #d8e4db;
  border-radius: 10px;
  padding: 10px;
  display: grid;
  gap: 8px;
  background: #fbfdfc;
}

.field-groups-panel {
  border: 1px solid #d8e4db;
  border-radius: 10px;
  padding: 10px;
  display: grid;
  gap: 8px;
  background: #fbfdfc;
  overflow: visible;
  position: relative;
  z-index: 2;
}

.field-groups-panel h2 {
  margin: 0;
}

.group-form {
  display: grid;
  gap: 7px;
}

.group-manage-form {
  border: 1px solid #d8e4db;
  border-radius: 10px;
  padding: 10px;
  display: grid;
  gap: 8px;
  background: #fff;
}

.group-manage-form.hidden {
  display: none;
}

.group-form textarea {
  min-height: 46px;
}

.group-chip.is-selected {
  border-color: #7aa68a;
  background: #dff0e4;
}

.groups-list button.group-chip {
  cursor: pointer;
}

.group-delete-help {
  color: #a53a2a;
  font-size: 0.85rem;
  font-weight: 600;
}

.group-delete-help.hidden {
  display: none;
}

.group-checkboxes {
  border: 1px solid #d8e4db;
  border-radius: 10px;
  background: #fff;
  display: grid;
  gap: 6px;
  max-height: 150px;
  overflow: auto;
  padding: 8px;
}

.group-checkbox {
  align-items: center;
  display: flex;
  gap: 8px;
  margin: 0;
}

.group-checkbox input {
  width: auto;
}

.checkbox-field {
  align-items: center;
  border: 1px solid #d8e4db;
  border-radius: 9px;
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 8px 9px;
}

.checkbox-field input {
  width: auto;
}

.form.hidden {
  display: none;
}

label {
  font-size: 0.84rem;
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}

input,
textarea {
  width: 100%;
  border: 1px solid #c7d7cc;
  border-radius: 9px;
  padding: 8px 9px;
  font: inherit;
  background: #fff;
}

textarea {
  min-height: 70px;
  resize: vertical;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.geometry-tools {
  display: grid;
  gap: 8px;
}

.map-wrap {
  padding: 10px;
  align-self: start;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 74vh;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.field-code-label {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid #b9cec0;
  color: #1f2d23;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  box-shadow: none;
  white-space: nowrap;
}

.field-code-label::before {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 23, 18, 0.45);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 3000;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  width: min(460px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
  padding: 20px;
  display: grid;
  gap: 14px;
}

.modal-card h2 {
  margin: 0;
  color: var(--danger);
  font-size: 1.15rem;
}

.modal-text {
  margin: 0;
  line-height: 1.45;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}


.map-wrap {
  position: relative;
}

.live-area-box {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #bfcfc5;
  border-radius: 8px;
  bottom: 22px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
  color: #15271d;
  font-size: 0.9rem;
  line-height: 1.45;
  min-width: 190px;
  padding: 10px 12px;
  pointer-events: none;
  position: absolute;
  right: 22px;
  white-space: pre-line;
  z-index: 900;
}

.live-area-box strong {
  display: block;
  margin-bottom: 4px;
}

.geometry-confirm-card h2 {
  color: var(--green);
}

.modal-actions.single-action {
  grid-template-columns: 1fr;
}

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

  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    padding-bottom: 14px;
  }

  .list {
    max-height: none;
  }

  #map {
    min-height: 58vh;
  }
}
