:root {
  --verde: #1a3a2a;
  --verde-scuro: #12281c;
  --verde-chiaro: #3f6b52;
  --crema: #f7f5ee;
  --bordo: #ddd7c4;
  --testo: #23291f;
  --muted: #726b58;
  --ok: #2f7d4f;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--crema);
  color: var(--testo);
}
.topbar {
  background: var(--verde-scuro);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.topbar-title { font-weight: 600; font-size: 18px; }
.btn-link {
  background: none; border: 1px solid rgba(255,255,255,.4); color: #fff;
  padding: 6px 12px; border-radius: 6px; cursor: pointer;
}
.container { max-width: 980px; margin: 0 auto; padding: 24px; }
.card {
  background: #fff; border: 1px solid var(--bordo); border-radius: 10px;
  padding: 20px; margin-bottom: 20px;
}
.card h2 { margin-top: 0; font-size: 16px; color: var(--verde); }
.card-header { display: flex; justify-content: space-between; align-items: center; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); gap: 4px; min-width: 0; }
input, select {
  width: 100%; min-width: 0; font-size: 14px; padding: 8px 10px; border: 1px solid var(--bordo);
  border-radius: 6px; color: var(--testo); background: #fff;
}
.btn-primary, .btn-secondary {
  border: none; border-radius: 6px; padding: 9px 16px; font-size: 14px;
  cursor: pointer; font-weight: 600;
}
.btn-primary { background: var(--verde); color: #fff; }
.btn-primary:hover { background: var(--verde-scuro); }
.btn-secondary { background: #fff; border: 1px solid var(--bordo); color: var(--verde); }
.btn-secondary:hover { background: var(--crema); }
.btn-secondary:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.immobile-row {
  padding: 16px 0;
  border-bottom: 1px solid var(--bordo);
}
.immobile-row:first-child { padding-top: 8px; }
.immobile-row:last-child { border-bottom: none; }
.immobile-row-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.immobile-index {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.immobile-fields {
  display: grid;
  grid-template-columns: 1.8fr 2.2fr 1fr 0.9fr 0.9fr 0.65fr;
  gap: 12px;
  align-items: end;
}
.f-prima-casa-wrap, .f-coltivatore-wrap {
  flex-direction: row; align-items: center; gap: 6px; font-size: 13px;
}
.hidden { display: none !important; }
.btn-remove-row {
  border-radius: 6px;
  background: none; border: 1px solid var(--bordo);
  color: var(--muted); font-size: 12px; font-weight: 600;
  padding: 4px 10px; cursor: pointer;
}
.btn-remove-row:hover { color: #fff; background: #b3261e; border-color: #b3261e; }

.risultati-header {
  display: flex; gap: 16px; align-items: center; margin-bottom: 12px;
}
.badge {
  background: var(--crema); border: 1px solid var(--bordo); border-radius: 999px;
  padding: 2px 10px; font-size: 12px; color: var(--verde);
}
.muted { color: var(--muted); font-size: 13px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabella-risultati th, .tabella-risultati td,
.tabella-storico th, .tabella-storico td {
  padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--bordo);
}
.tabella-risultati th:first-child, .tabella-risultati td:first-child,
.tabella-risultati th:nth-child(2), .tabella-risultati td:nth-child(2),
.tabella-storico th:first-child, .tabella-storico td:first-child,
.tabella-storico th:nth-child(2), .tabella-storico td:nth-child(2) {
  text-align: left;
}
.tabella-risultati tfoot td { border-top: 2px solid var(--verde); border-bottom: none; }
.tabella-storico .link-azione {
  background: none; border: none; color: var(--verde-chiaro); cursor: pointer;
  font-size: 13px; margin-right: 8px; padding: 0;
}
.tabella-storico .link-azione.danger { color: #b3261e; }

@media print {
  .no-print { display: none !important; }
  .card { border: none; padding: 0; }
  body { background: #fff; }
}
