:root {
  --ink: #2b2118;
  --paper: #f7f3ee;
  --card: #ffffff;
  --accent: #7a1f2b;
  --accent-soft: #f3e3e5;
  --muted: #8a7a6d;
  --line: #e5dcd2;
  --ok: #2f6f3e;
  --warn: #9a6b0f;
  --err: #a3272f;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Georgia", "Times New Roman", serif;
  background: var(--paper);
  color: var(--ink);
}

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--ink);
  color: #e8e0d6;
  display: flex;
  flex-direction: column;
  padding: 1.2rem 0;
}
.brand {
  font-size: 1.15rem;
  font-weight: bold;
  padding: 0 1.2rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar nav { display: flex; flex-direction: column; padding: .6rem 0; }
.sidebar nav a {
  color: #e8e0d6;
  text-decoration: none;
  padding: .5rem 1.2rem;
  font-size: .95rem;
}
.sidebar nav a:hover { background: rgba(255,255,255,.07); }
.sidebar nav a.active {
  background: var(--accent);
  color: #fff;
}
.sidebar-section {
  padding: .8rem 1.2rem .2rem;
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(232,224,214,.55);
}
.sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.2rem 0;
  border-top: 1px solid rgba(255,255,255,.12);
  font-size: .85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.linklike {
  background: none;
  border: none;
  color: #d8a7ad;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
}

.content { flex: 1; padding: 2rem 2.5rem; max-width: 1200px; }
.content-anon {
  max-width: none;
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

h1 { font-size: 1.6rem; margin: 0 0 1.2rem; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 .6rem; }
a { color: var(--accent); }

.flash {
  padding: .6rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
}
.flash-success { background: #e4efe6; border-color: var(--ok); }
.flash-warning { background: #f6ecd8; border-color: var(--warn); }
.flash-error   { background: #f6dddf; border-color: var(--err); }

.cards { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.4rem;
  min-width: 160px;
}
.card .num { font-size: 1.9rem; font-weight: bold; color: var(--accent); }
.card .label { color: var(--muted); font-size: .85rem; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.2rem 1.4rem;
  margin-bottom: 1.4rem;
}

table.list {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  font-size: .92rem;
}
table.list th, table.list td {
  text-align: left;
  padding: .5rem .8rem;
  border-bottom: 1px solid var(--line);
}
table.list th {
  background: #efe8df;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
table.list tr:last-child td { border-bottom: none; }
table.list td.num { text-align: right; white-space: nowrap; }

.toolbar {
  display: flex;
  gap: .6rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.toolbar input[type="text"], .toolbar select {
  padding: .45rem .6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: var(--card);
}
.toolbar .spacer { flex: 1; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: .5rem 1rem;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #641822; }
.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.btn-secondary:hover { background: var(--accent-soft); }
.btn-danger { background: var(--err); }
.btn-sm { padding: .25rem .6rem; font-size: .85rem; }

form.stacked p { margin: 0 0 .9rem; }
form.stacked label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
form.stacked input, form.stacked select, form.stacked textarea {
  width: 100%;
  padding: .5rem .7rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: var(--card);
}
form.stacked input[type="checkbox"] { width: auto; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0 1.2rem;
}
.errorlist { color: var(--err); margin: .2rem 0; padding-left: 1rem; font-size: .85rem; }
.helptext { color: var(--muted); font-size: .8rem; }

.login-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 2.2rem 2.6rem;
  width: 360px;
}
.login-box h1 { text-align: center; }

.badge {
  display: inline-block;
  padding: .1rem .55rem;
  border-radius: 99px;
  font-size: .75rem;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge-ok { background: #e4efe6; color: var(--ok); }
.badge-err { background: #f6dddf; color: var(--err); }
.badge-warn { background: #f6ecd8; color: var(--warn); }

.progress {
  height: 10px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
  margin: .5rem 0;
}
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .4s; }

pre.log {
  background: #201a15;
  color: #e8e0d6;
  padding: .8rem 1rem;
  border-radius: 8px;
  font-size: .78rem;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
}
.pagination { margin-top: 1rem; display: flex; gap: .6rem; align-items: center; font-size: .9rem; }
.muted { color: var(--muted); }

/* Pagina di modifica: contenuto principale + colonna laterale */
.edit-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1.4rem;
  align-items: start;
}
.edit-side { position: sticky; top: 1.2rem; }
.edit-main .panel:last-child, .edit-side .panel:last-child { margin-bottom: 0; }
.panel-title {
  margin: 0 0 .9rem;
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: .45rem;
}
.field-wide { grid-column: 1 / -1; }
.btn-row { display: flex; gap: .6rem; margin-top: .8rem; }
.btn-row .btn { flex: 1; text-align: center; }
@media (max-width: 980px) {
  .edit-layout { grid-template-columns: 1fr; }
  .edit-side { position: static; }
}

.image-preview {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}
.image-preview-side { margin-bottom: .8rem; }
.image-preview-side img { max-height: 140px; }
.image-preview img {
  max-height: 180px;
  max-width: 140px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 4px;
}
.image-hint { font-size: .8rem; }

/* Editor descrizione (WYSIWYG) */
.rte { border: 1px solid var(--line); border-radius: 6px; background: var(--card); }
.rte-toolbar {
  display: flex;
  gap: .3rem;
  padding: .35rem .5rem;
  border-bottom: 1px solid var(--line);
  background: #efe8df;
  border-radius: 6px 6px 0 0;
}
.rte-toolbar button {
  font: inherit;
  font-size: .8rem;
  padding: .15rem .55rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--card);
  cursor: pointer;
}
.rte-toolbar button:hover:not(:disabled) { background: var(--accent-soft); }
.rte-toolbar button:disabled { opacity: .45; cursor: default; }
.rte-toolbar button:first-child { font-weight: bold; }
.rte-area {
  min-height: 180px;
  max-height: 420px;
  overflow-y: auto;
  padding: .7rem .9rem;
  outline: none;
}
.rte-area h4 {
  margin: .8rem 0 .25rem;
  font-size: .95rem;
  color: var(--accent);
}
.rte-area p { margin: .3rem 0; }
.rte-area ul { margin: .3rem 0; padding-left: 1.4rem; }
form.stacked textarea.rte-source {
  border: none;
  border-radius: 0 0 6px 6px;
  min-height: 180px;
  font-family: monospace;
  font-size: .8rem;
}

td.thumb { width: 44px; }
td.thumb img {
  height: 40px;
  width: 32px;
  object-fit: contain;
  display: block;
  border-radius: 3px;
}
