:root { --ink: #111; --graphite: #3a3a3a; --grey: #777; --stone: #b5b5b0; --line: #e6e6e3; --mist: #f6f6f4; --ok: #1d6b3a; --warn: #8a4b00;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif; color: var(--graphite); }
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: #fff; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.brand { font-family: Georgia, "Times New Roman", serif; letter-spacing: .26em; font-size: 17px; color: var(--ink); }
.brand span { display: block; font-family: inherit; font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--grey); margin-top: 6px; font-family: -apple-system, system-ui, sans-serif; }

/* Accesso */
.login { min-height: 100%; display: grid; place-items: center; background: var(--mist); padding: 24px; }
.login-box { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); padding: 40px 36px; display: grid; gap: 18px; }
.login-box .brand { margin-bottom: 10px; }
.login-box { max-width: 420px; }
.step { display: grid; gap: 16px; }
.step-title { font-family: Georgia, serif; font-size: 22px; color: var(--ink); }
.hint { font-size: 14px; line-height: 1.55; color: var(--graphite); }
.hint.small, .hint .small { font-size: 12px; color: var(--grey); }
ol.hint { padding-left: 20px; display: grid; gap: 6px; }
.code { font-size: 26px; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; padding: 12px; }
.qr { display: flex; justify-content: center; }
.qr svg { width: 220px; height: 220px; }
.secret { display: block; margin-top: 8px; font-size: 14px; letter-spacing: .08em; word-break: break-all; background: var(--mist); padding: 8px 10px; color: var(--ink); user-select: all; }
details summary { cursor: pointer; }
.codes { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; background: var(--mist); padding: 14px 18px; font-family: ui-monospace, Menlo, monospace; font-size: 15px; color: var(--ink); }
.row { display: flex; gap: 8px; }
.row button { flex: 1; }
label { display: grid; gap: 6px; font-size: 12px; letter-spacing: .04em; color: var(--grey); }
input, textarea { border: 1px solid var(--line); padding: 10px 12px; font-size: 15px; color: var(--ink); background: #fff; outline: none; }
input:focus, textarea:focus { border-color: var(--ink); }
button { cursor: pointer; border: 1px solid var(--ink); background: #fff; padding: 9px 16px; font-size: 13px; }
button:disabled { opacity: .4; cursor: default; }
.login-box button, .primary { background: var(--ink); color: #fff; }
.primary:hover:not(:disabled) { background: var(--graphite); }
.ghost { border-color: var(--line); }
.ghost:hover:not(:disabled) { border-color: var(--ink); }
.link { border: 0; background: none; padding: 0; text-decoration: underline; color: var(--grey); font-size: 13px; }
.err { color: #a11; font-size: 13px; min-height: 18px; }

/* Pannello */
.app { display: grid; grid-template-columns: 290px 1fr; height: 100%; }
.side { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--mist); }
.side .brand { padding: 22px 20px 18px; }
.side input { margin: 0 16px 10px; }
.pages { overflow-y: auto; flex: 1; padding: 0 8px 12px; }
.pages h4 { font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--grey); padding: 14px 10px 6px; font-weight: 600; }
.pages a { display: block; padding: 7px 10px; font-size: 14px; color: var(--ink); text-decoration: none; border-radius: 3px; line-height: 1.3; }
.pages a small { display: block; font-size: 11px; color: var(--grey); }
.pages a:hover { background: #ececea; }
.pages a.on { background: var(--ink); color: #fff; }
.pages a.on small { color: #bbb; }
.side-foot { border-top: 1px solid var(--line); padding: 14px 20px; display: flex; justify-content: space-between; font-size: 13px; }
.side-foot a { color: var(--ink); }

.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.empty { max-width: 620px; margin: 12vh auto; padding: 0 24px; line-height: 1.6; }
.empty h1 { font-family: Georgia, serif; font-weight: 400; font-size: 34px; color: var(--ink); margin-bottom: 14px; }
.empty p { margin-bottom: 12px; }
.editor { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.where { font-size: 13px; color: var(--grey); display: flex; gap: 12px; align-items: baseline; }
.where span { color: var(--ink); font-weight: 600; }
.where a { color: var(--grey); }
.actions { display: flex; gap: 8px; align-items: center; }
.status { font-size: 12px; color: var(--grey); margin-right: 6px; }
.status.dirty { color: var(--warn); }
.status.ok { color: var(--ok); }
.meta { display: grid; grid-template-columns: 1fr 1.4fr; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: #fcfcfb; }
.meta small { float: right; color: var(--stone); }
.meta small.long { color: var(--warn); }
.meta textarea { resize: vertical; min-height: 42px; }
.tools { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 8px 18px; border-bottom: 1px solid var(--line); }
.tools button { border-color: var(--line); padding: 5px 10px; font-size: 13px; min-width: 34px; }
.tools button:hover { border-color: var(--ink); }
.tools .sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
.note { font-size: 12px; color: var(--grey); padding: 6px 18px; }
.note.warn { color: var(--warn); }
iframe { flex: 1; border: 0; width: 100%; min-height: 0; background: #fff; }

dialog { border: 1px solid var(--ink); padding: 26px; max-width: 640px; width: calc(100% - 40px); margin: auto; }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
dialog h2 { font-family: Georgia, serif; font-weight: 400; font-size: 24px; color: var(--ink); margin-bottom: 8px; }
.small { font-size: 13px; color: var(--grey); margin-bottom: 14px; }
#versions { list-style: none; max-height: 50vh; overflow-y: auto; border-top: 1px solid var(--line); margin-bottom: 16px; }
#versions li { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; gap: 10px; }
#dlgHtml { max-width: 900px; }
#htmlArea { width: 100%; height: 55vh; font-family: ui-monospace, Menlo, monospace; font-size: 13px; line-height: 1.5; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { max-height: 38vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .meta { grid-template-columns: 1fr; }
}

@media print {
  body * { visibility: hidden; }
  #backupStep, #backupStep * { visibility: visible; }
  #backupStep { position: absolute; top: 0; left: 0; }
  #backupStep button { display: none; }
}
