/* Mini CMS — stile del pannello */
:root {
  --brand: #2f5d50;
  --bg: #f4f5f2;
  --card: #fff;
  --ink: #1d2320;
  --muted: #69716c;
  --line: #e2e5df;
  --danger: #b4372e;
  --ok: #2f7a4f;
  --r: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 4px 16px rgba(20, 30, 25, .04);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 4px; }
code { background: #eef0ec; padding: 1px 6px; border-radius: 5px; font-size: 13px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.right { text-align: right; }
.pad { padding: 16px; margin: 0; }
[hidden] { display: none !important; }

/* ---------- struttura ---------- */
.shell { display: flex; min-height: 100vh; }
.side { width: 256px; flex: none; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 30; }
.side-brand, .login-brand { display: flex; gap: 12px; align-items: center; padding: 20px 18px 16px; }
.side-brand strong, .login-brand strong { display: block; font-size: 15px; line-height: 1.2; }
.side-brand small, .login-brand small { color: var(--muted); font-size: 12px; }
.dot { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); flex: none; box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .25); }
.side-nav { padding: 4px 10px; flex: 1; }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 14.5px; }
.side-nav a:hover { background: #f1f3ef; }
.side-nav a.on { background: color-mix(in srgb, var(--brand) 12%, #fff); color: var(--brand); font-weight: 600; }
.side-nav .ico { width: 22px; text-align: center; opacity: .8; }
.nav-h { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 16px 10px 6px; }
.badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 1px 8px; }
.side-foot { padding: 14px 16px 18px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.main { flex: 1; min-width: 0; }
.topbar { display: none; }
.content { max-width: 1120px; margin: 0 auto; padding: 32px 32px 120px; }

/* ---------- elementi ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px; }
.card.narrow { max-width: 460px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: 13px; color: var(--muted); margin: 0 0 6px !important; }
.crumb a { color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-bottom: 18px; }
.page-card { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--ink); margin: 0; transition: transform .15s, box-shadow .15s, border-color .15s; }
.page-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--brand) 40%, #fff); box-shadow: 0 8px 24px rgba(20, 30, 25, .08); }
.page-card strong { font-size: 17px; }
.ico.big { font-size: 22px; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: color-mix(in srgb, var(--brand) 10%, #fff); color: var(--brand); margin-bottom: 8px; }
.notice { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--ink); border-left: 4px solid var(--brand); }
.tip { background: #fbfaf4; }
.tip p { margin: 4px 0 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600; font-size: 14px; padding: 9px 16px; border-radius: 9px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #c9cec6; background: #fafbf9; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: #ecc9c5; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.linkbtn { background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; padding: 4px 0; text-decoration: underline; }

.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-weight: 500; }
.flash-ok { background: #e6f3ea; color: #1f5a37; border: 1px solid #c4e2cf; }
.flash-error { background: #fbeae8; color: #8b2a22; border: 1px solid #f0c9c4; }
.flash-info { background: #eef2f6; color: #2e4357; border: 1px solid #d6e0ea; }

/* ---------- moduli ---------- */
.lbl { display: block; font-weight: 600; font-size: 13.5px; margin: 0 0 6px; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password], input:not([type]), select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid #d5d9d2; border-radius: 9px; padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
input:focus, select:focus, textarea:focus, .rich-area:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.help { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 20px; }
.field { min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field.check label { display: flex; gap: 8px; align-items: center; font-weight: 600; font-size: 14px; padding-top: 26px; }
.field.check input { width: 18px; height: 18px; accent-color: var(--brand); }

.login { max-width: 400px; margin: 0 auto; display: grid; gap: 4px; padding: 10px 28px 26px; }
.login .lbl { margin-top: 14px; }
.login .btn { margin-top: 20px; }
.login-brand { padding: 22px 0 10px; }
.bare-main { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.bare-main > .card, .bare-main > form { width: 100%; }
.pw { position: relative; }
.pw input { padding-right: 82px; }
.pw .linkbtn { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); }

/* editor formattato */
.rich { border: 1px solid #d5d9d2; border-radius: 9px; background: #fff; }
.rich:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.rich-bar { display: flex; gap: 4px; padding: 6px; border-bottom: 1px solid var(--line); background: #fafbf9; border-radius: 9px 9px 0 0; flex-wrap: wrap; }
.rich-bar button { font: inherit; font-size: 13px; border: 1px solid transparent; background: none; padding: 4px 10px; border-radius: 6px; cursor: pointer; color: var(--ink); }
.rich-bar button:hover { background: #fff; border-color: var(--line); }
.rich-area { min-height: 90px; padding: 10px 12px; outline: none; border: 0 !important; box-shadow: none !important; border-radius: 0 0 9px 9px; }
.rich-area[data-inline] { min-height: 46px; }
.rich-area p { margin: 0 0 .7em; }
.rich-area p:last-child { margin-bottom: 0; }
.rich-area ul { margin: 0 0 .7em; padding-left: 1.3em; }

/* media */
.media { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.media-preview { width: 180px; height: 120px; border-radius: 9px; background: #eef0ec repeating-conic-gradient(#e6e9e3 0 25%, #f1f3ef 0 50%) 0 0 / 16px 16px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); flex: none; }
.media-preview img, .media-preview video { width: 100%; height: 100%; object-fit: cover; }
.media-preview.file { width: auto; min-width: 180px; height: auto; min-height: 48px; padding: 10px 14px; background: #f5f6f3; }
.media-preview .empty { font-size: 12.5px; color: var(--muted); }
.media-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.media-status { font-size: 12.5px; color: var(--ok); }
.media.busy .media-preview { opacity: .5; }

/* elenchi */
.list { border: 1px dashed #cfd4cc; border-radius: var(--r); padding: 14px; background: #fafbf9; }
.list-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.list-head .lbl { margin: 0; }
.count { font-size: 12px; background: #e8ebe5; border-radius: 99px; padding: 0 8px; color: var(--muted); font-weight: 600; }
.list-items { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.item { min-width: 0; }
.item { background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.item > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; min-height: 48px; }
.item > summary::-webkit-details-marker { display: none; }
.item > summary::after { content: "▾"; color: var(--muted); margin-left: 4px; transition: transform .15s; }
.item[open] > summary::after { transform: rotate(180deg); }
.item[open] > summary { border-bottom: 1px solid var(--line); }
.drag { color: #b8bdb5; font-size: 12px; letter-spacing: -2px; }
.item-thumb { width: 44px; height: 32px; object-fit: cover; border-radius: 5px; flex: none; }
.item-title { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-tools { display: flex; gap: 2px; }
.item-tools button { width: 30px; height: 30px; border: 1px solid transparent; background: none; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 14px; }
.item-tools button:hover { background: #f1f3ef; border-color: var(--line); color: var(--ink); }
.item-tools button.danger:hover { color: var(--danger); background: #fbeae8; }
.item-body { padding: 16px; }
.list-foot { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.list .list { background: #fff; }

/* modifica pagina */
.edit-wrap { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 24px; align-items: start; }
.toc { position: sticky; top: 24px; display: grid; gap: 2px; font-size: 13.5px; max-height: calc(100vh - 48px); overflow-y: auto; }
.toc a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-left: 2px solid var(--line); }
.toc a:hover { color: var(--ink); }
.toc a.on { color: var(--brand); border-left-color: var(--brand); font-weight: 600; }
.sec { scroll-margin-top: 20px; }
.sec-head { margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.sec-head p { margin: 2px 0 0; font-size: 13.5px; }
.savebar { position: sticky; bottom: 16px; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 12px; background: rgba(255, 255, 255, .94); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px 12px 18px; box-shadow: 0 10px 30px rgba(20, 30, 25, .12); }
.dirty-msg { color: var(--muted); font-size: 14px; }
.savebar.is-dirty { border-color: color-mix(in srgb, var(--brand) 45%, #fff); }
.savebar.is-dirty .dirty-msg { color: #8a5a00; font-weight: 600; }
.savebar.is-dirty .dirty-msg::before { content: "●  "; color: #d39100; }

/* tabelle, richieste */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.table form { display: inline; }
.req-wrap { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; align-items: start; }
.req-list { padding: 6px; max-height: 70vh; overflow-y: auto; }
.req { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); }
.req:hover { background: #f4f5f2; }
.req.on { background: color-mix(in srgb, var(--brand) 10%, #fff); }
.req small { color: var(--muted); font-size: 12px; }
.req .muted { grid-column: 1 / -1; font-size: 13px; }
.req.unread strong::before { content: "● "; color: var(--danger); }
.dl { display: grid; grid-template-columns: 160px 1fr; gap: 10px 16px; margin: 16px 0 20px; }
.dl dt { font-weight: 600; color: var(--muted); font-size: 13.5px; }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-actions form { display: inline; }
.prose h2 { margin-top: 22px; }
.prose h2:first-child { margin-top: 0; }
.prose p { margin: 4px 0 0; color: #3a423e; }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .edit-wrap { grid-template-columns: 1fr; }
  .toc { position: static; display: flex; overflow-x: auto; gap: 6px; max-height: none; padding-bottom: 4px; }
  .toc a { border: 1px solid var(--line); border-radius: 99px; white-space: nowrap; background: #fff; }
  .req-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .side { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .15); }
  body.side-open .side { transform: none; }
  .topbar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 25; background: #fff; border-bottom: 1px solid var(--line); padding: 10px 14px; font-weight: 600; }
  .menu-btn { font-size: 20px; border: 1px solid var(--line); background: #fff; border-radius: 8px; width: 40px; height: 38px; cursor: pointer; }
  .content { padding: 20px 14px 120px; }
  .grid { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .list { padding: 10px; }
  .item-body { padding: 12px; }
  .item-tools button { width: 34px; height: 34px; }
  h1 { font-size: 22px; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 10px; }
  .media-preview { width: 100%; height: 160px; }
  .savebar { bottom: 10px; }
}

.field.checks .checks-row { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; }
.field.checks label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; cursor: pointer; }
