/* Backend dello studio */
.admin .brand { color: var(--ink); text-decoration: none; }
.page-head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { margin-top: 4px; }
.back { display: inline-block; margin-bottom: 12px; font-size: 14px; font-weight: 550; text-decoration: none; }
.back:hover { text-decoration: underline; }

.login { max-width: 380px; margin: 12vh auto 0; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

table.list { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.list th { text-align: left; font-size: 12.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--line); }
table.list td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover td { background: var(--surface-2); }
table.list .title { font-weight: 600; }
.table-card { padding: 0; overflow: hidden; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); display: grid; gap: 12px; justify-items: center; }
.show-sm { display: none; }
@media (max-width: 700px) {
  table.list .hide-sm { display: none; }
  .show-sm { display: block; }
}

.doc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.doc-item { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.doc-icon { width: 38px; height: 46px; border-radius: 5px; background: #fff; border: 1px solid var(--line-2); display: grid; place-items: center; font-size: 10px; font-weight: 800; color: var(--danger); }
.doc-item .name { font-weight: 600; overflow-wrap: anywhere; text-decoration: none; color: var(--ink); }
.doc-item .name:hover { color: var(--accent); }
.doc-item .meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 3px; }
.doc-item .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.doc-item .warnings { grid-column: 2 / -1; font-size: 12.5px; color: var(--warn); }
@media (max-width: 640px) { .doc-item { grid-template-columns: 38px minmax(0, 1fr); } .doc-item .actions { grid-column: 1 / -1; justify-content: flex-start; } }

.upload {
  position: relative; display: grid; place-items: center; gap: 4px; padding: 22px; margin-bottom: 14px;
  border: 1.5px dashed var(--line-2); border-radius: 10px; background: var(--surface-2); text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload:hover, .upload.over { border-color: var(--accent); background: var(--accent-soft); }
.upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload .progress { width: min(320px, 80%); margin-top: 6px; }

.link-box { display: flex; gap: 6px; }
.link-box input { font-family: var(--mono); font-size: 12.5px; }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }

/* editor delle zone */
.editor-bar {
  position: sticky; top: 56px; z-index: 25; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.editor-bar .doc-name { font-weight: 650; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-hint { padding: 8px 16px; font-size: 13.5px; color: var(--ink-2); background: var(--accent-soft); border-bottom: 1px solid var(--line); }
.editor-area { background: #e6e4de; min-height: 70vh; padding: 0 12px; }
.save-state { font-size: 13px; color: var(--muted); min-width: 90px; text-align: right; }
.save-state.err { color: var(--danger); }
.zoom { display: flex; align-items: center; gap: 2px; }
.zoom output { min-width: 48px; text-align: center; font-size: 13px; font-weight: 600; color: var(--ink-2); }

.editable .pdf-overlay { cursor: crosshair; }
.field-outline { position: absolute; border: 1px dashed var(--field-line); background: rgba(221, 0, 0, .04); pointer-events: none; border-radius: 2px; }
.rubber { position: absolute; border: 2px solid var(--accent); background: rgba(221, 0, 0, .08); pointer-events: none; }
.zone.admin { cursor: move; touch-action: none; }
.zone.admin.selected { border-style: solid; border-color: var(--accent); background: rgba(221, 0, 0, .1); color: var(--accent); z-index: 10; }
.zone.admin.optional:not(.selected) { border-style: dotted; }
.zone.admin .handle {
  position: absolute; right: -6px; bottom: -6px; width: 14px; height: 14px; border-radius: 3px;
  background: #fff; border: 2px solid var(--zone); cursor: nwse-resize;
}
.zone.admin.selected .handle { border-color: var(--accent); }
.zone.readonly { cursor: default; }
.zone-panel {
  position: absolute; left: 0; top: calc(100% + 8px); z-index: 11; width: min(280px, 80vw); padding: 12px;
  display: grid; gap: 10px; cursor: default;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg);
  font-size: 14px; font-weight: 400; text-align: left;
}
.zone-panel.right { left: auto; right: 0; }
.zone-panel input[type=text] { min-height: 34px; padding: 5px 9px; }
