:root {
  color-scheme: light;
  --bg: #f7f6f3;
  --surface: #ffffff;
  --text: #23201c;
  --muted: #6b655c;
  --border: #ddd8cf;
  --accent: #7a3b2e;
  --accent-contrast: #ffffff;
  --error: #b3261e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 600;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar nav a {
  color: var(--text);
  text-decoration: none;
}

.topbar nav a:hover {
  text-decoration: underline;
}

main {
  max-width: 720px;
  margin: 2rem auto;
  padding: 0 1.25rem;
}

main.wide {
  max-width: 1000px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
}

.card.narrow {
  max-width: 360px;
  margin: 3rem auto;
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

form.inline {
  display: inline;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--muted);
}

input, select, textarea {
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  font-family: inherit;
}

textarea {
  resize: vertical;
}

button {
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 1rem;
  cursor: pointer;
}

button:hover {
  opacity: 0.9;
}

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

th, td {
  text-align: left;
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--border);
}

.errore {
  color: var(--error);
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.utente-connesso {
  color: var(--muted);
  font-size: 0.9rem;
}

.password-field {
  display: flex;
  gap: 0.5rem;
}

.password-field input {
  flex: 1;
}

.toggle-password {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.avviso {
  background: #fbf0d9;
  border: 1px solid #e8c97a;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}

.avviso ul {
  margin: 0;
  padding-left: 1.2rem;
}

.block-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1rem 0;
}

.block-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
}

.block-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.block-badge {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  margin-right: auto;
}

.block-controls button {
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.block-heading-input {
  font-weight: 600;
  width: 100%;
}

.field-inputs {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 0.6rem;
  align-items: end;
}

.field-inputs.inline {
  display: inline-grid;
  margin: 0.2rem 0.4rem 0.2rem 0;
  min-width: 220px;
  vertical-align: middle;
  background: var(--bg);
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
}

.opzioni-wrapper {
  grid-column: 1 / -1;
}

.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.checkbox-label input {
  width: auto;
}

.paragraph-spans {
  line-height: 2.4;
}

.paragraph-text-input {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  min-width: 6rem;
}

@media (max-width: 640px) {
  .field-inputs {
    grid-template-columns: 1fr;
  }
}
