:root {
  /* Colore principale (configurabile in Impostazioni): blu istituzionale, 6.9:1 con il bianco. */
  --accent: #1f5c99;
  --accent-strong: color-mix(in srgb, var(--accent) 82%, black);
  --accent-soft: color-mix(in srgb, var(--accent) 9%, white);
  --accent-soft-2: color-mix(in srgb, var(--accent) 18%, white);
  /* Blu notte per la barra laterale e le superfici scure. */
  --ink: #0f2338;
  --ink-2: #1b3554;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --line: #e3e7ee;
  --line-2: #cfd6e0;
  --field: #7f8b9c;      /* bordi dei campi: almeno 3:1 sul bianco (WCAG 1.4.11) */
  --text: #18212d;
  --muted: #5a6475;      /* 5.5:1 sullo sfondo */
  /* Stati: testo almeno 4.5:1 sul proprio fondo chiaro; mai solo il colore a dare l'informazione. */
  --ok: #17714a;
  --ok-soft: #e3f3ea;
  --warn: #8a5300;
  --warn-soft: #fcf1dc;
  --err: #b42318;
  --err-soft: #fbe9e7;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(15, 30, 50, .05), 0 6px 20px rgba(15, 30, 50, .06);
  --shadow-lg: 0 12px 40px rgba(15, 30, 50, .2);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: 14px; }
.stack-sm > * + * { margin-top: 8px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.err-text { color: var(--err); }
.pad { padding: 10px 14px; }
svg.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* --------------------------------------------------------------- pulsanti e campi */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 13px;
  border: 1px solid var(--line-2); border-radius: 6px; background: var(--panel); cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: #f1f4f8; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.tool { border-color: transparent; background: transparent; color: var(--text); }
.btn.tool:hover { background: var(--accent-soft); color: var(--accent); }
.btn.tool.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft-2); }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: var(--err-soft); border-color: #efb9b3; }
.btn.danger-solid { background: var(--err); border-color: var(--err); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(15, 30, 55, .06); }
.btn.inv { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .2); color: #fff; }
.btn.inv:hover { background: rgba(255, 255, 255, .18); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.icon-only { width: 34px; padding: 0; }
.btn.sm.icon-only { width: 28px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-weight: 600; }

.field { display: block; }
.field > span { display: block; margin-bottom: 4px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.input {
  width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--field); border-radius: 6px; background: #fff; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
textarea.input { height: auto; min-height: 90px; padding: 8px 10px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft-2); }
.input.sm { height: 28px; font-size: 13px; padding: 0 6px; }
.check { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.check.inv { color: #fff; font-size: 13px; align-items: center; }
.check.inv input { margin-top: 0; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
.switch { appearance: none; width: 34px; height: 20px; border-radius: 10px; background: var(--line-2); position: relative; cursor: pointer; flex: none; transition: background .15s; margin-top: 1px; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: left .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { left: 16px; }
.switch-row { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.switch-row > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.switch-ico { width: 34px; display: grid; place-items: center; color: var(--muted); }
.color { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--line-2); border-radius: 6px; background: #fff; cursor: pointer; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.two-col > * + * { margin-top: 0 !important; }

.badge { display: inline-flex; align-items: center; height: 19px; padding: 0 7px; border-radius: 10px; font-size: 11px; font-weight: 600; background: #eceff4; color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.info, .badge.accent { background: var(--accent-soft); color: var(--accent); }
.count-pill { margin-left: auto; min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px; background: #e9edf2; color: var(--muted); font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.kv > span { color: var(--muted); }
.kv > b { font-weight: 600; text-align: right; overflow-wrap: anywhere; }

/* --------------------------------------------------------------- accesso */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(300px, 42%) 1fr; }
.auth-side {
  padding: 48px; display: flex; flex-direction: column; justify-content: flex-end; gap: 14px; color: #fff;
  background: radial-gradient(circle at 15% 15%, color-mix(in srgb, var(--accent) 70%, white) 0, var(--accent) 35%, var(--ink) 100%);
}
.auth-side h1 { font-size: 30px; }
.auth-side p { max-width: 420px; color: rgba(255, 255, 255, .78); }
.auth-brand { margin-bottom: auto; }
.auth-main { display: grid; place-items: center; padding: 32px; background: var(--panel); }
.auth-card { width: 100%; max-width: 440px; }
.auth-card h2 { font-size: 22px; }
.auth-card .btn.block { height: 40px; }
.terms-text { max-height: 46vh; overflow: auto; padding: 14px 16px; border: 1px solid var(--line); border-radius: 6px; background: #f8fafc; white-space: pre-wrap; }
.error-text { color: var(--err); font-size: 13px; min-height: 18px; }
.brand-mark, .brand-logo { display: block; object-fit: contain; }
.brand-mark.sm { width: 30px; height: 30px; }
.brand-mark.md { width: 34px; height: 34px; }
.brand-mark.lg { width: 52px; height: 52px; }
.brand-logo.sm { width: 40px; height: 34px; }
.brand-logo.md { max-width: 140px; height: 34px; }
.brand-logo.lg { max-width: 240px; height: 60px; background: #fff; border-radius: 8px; padding: 6px 10px; }

/* --------------------------------------------------------------- struttura */
.shell { display: grid; grid-template-columns: 60px 1fr; height: 100vh; }
.rail { background: var(--ink); display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 0; }
.rail-logo { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 10px; background: #fff; border-radius: 10px; }
.rail-btn { width: 42px; height: 42px; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: #9fb1c8; cursor: pointer; }
.rail-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.rail-btn svg.icon { width: 20px; height: 20px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 700; flex: none; }
.avatar.sm { width: 28px; height: 28px; font-size: 10.5px; }
.workspace { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.project-head { display: flex; align-items: flex-end; gap: 28px; padding: 0 20px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 64px; }
.project-title { padding: 10px 0 12px; min-width: 0; }
.project-name { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px; }
.project-sub { font-size: 12px; color: var(--muted); }
.tabs-nav { display: flex; gap: 4px; align-self: stretch; align-items: flex-end; overflow-x: auto; }
.tabs-nav a { padding: 0 14px 13px; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; text-decoration: none; white-space: nowrap; }
.tabs-nav a:hover { color: var(--text); }
.tabs-nav a.active { color: var(--accent); border-bottom-color: var(--accent); }
.head-tools { margin-left: auto; display: flex; gap: 4px; align-self: center; }
.head-btn { position: relative; width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.head-btn:hover { background: var(--accent-soft); color: var(--accent); }
.head-btn svg.icon { width: 20px; height: 20px; }
.head-btn .dot { position: absolute; top: 4px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid #fff; }
.main { flex: 1; min-height: 0; overflow: auto; position: relative; }
.page { padding: 22px 24px 40px; max-width: 1320px; }
.page > * + * { margin-top: 16px; }
.narrow-page { max-width: 860px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-body { padding: 16px; }
.empty { padding: 34px 16px; text-align: center; color: var(--muted); }

/* --------------------------------------------------------------- indice */
.docs-layout { display: grid; grid-template-columns: 1fr; height: 100%; min-height: 0; }
.docs-layout.with-viewer { grid-template-columns: minmax(320px, 34%) 1fr; }
.docs-layout.with-viewer .c-num, .docs-layout.with-viewer .c-fmt, .docs-layout.with-viewer .c-date, .docs-layout.with-viewer .c-user { display: none; }
.docs-layout.with-viewer .c-name { min-width: 0; }
.docs-layout.with-viewer .name-cell .nm > span, .docs-layout.with-viewer .name-cell .nm { white-space: nowrap; }
.docs-layout.viewer-full { grid-template-columns: 1fr; }
.docs-layout.viewer-full .index-pane { display: none; }
.index-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); }
.index-toolbar { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.search-box { position: relative; flex: 0 1 280px; min-width: 160px; }
.search-box svg { position: absolute; left: 9px; top: 9px; color: var(--muted); }
.search-box .input { padding-left: 30px; }
.input.mode { width: auto; flex: none; }
.index-bars:empty { display: none; }
.infobar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--accent-soft); border-bottom: 1px solid var(--accent-soft-2); font-size: 13px; flex-wrap: wrap; }
.infobar.selection { background: #f1f4f8; border-bottom-color: var(--line); }
.infobar.perm-bar { background: var(--ink); color: #fff; border-bottom: 0; }
.infobar.perm-bar .muted-inv { color: #9fb1c8; }
.infobar.view-as { background: var(--warn-soft); border-bottom-color: #f1dcb0; }
.grid-wrap { flex: 1; overflow: auto; position: relative; min-height: 0; }
.grid-wrap.dragging::after {
  content: "Rilascia per caricare nella cartella selezionata (o su una cartella dell'indice)"; position: absolute; inset: 8px; display: grid; place-items: center;
  border: 3px dashed var(--accent); border-radius: 12px; background: color-mix(in srgb, var(--accent-soft) 92%, transparent); color: var(--accent); font-size: 16px; font-weight: 600; pointer-events: none; padding: 20px; text-align: center;
}
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.grid th { position: sticky; top: 0; z-index: 2; background: #f8fafc; text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 9px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid td { padding: 0 8px; height: 36px; border-bottom: 1px solid #eef2f6; vertical-align: middle; }
table.grid tr.irow { cursor: pointer; }
table.grid tr.irow:hover td { background: #f7f9fb; }
table.grid tr.selected td { background: var(--accent-soft); }
table.grid tr.open td { background: var(--accent-soft-2); }
table.grid tr.checked td { background: #eef3f9; }
table.grid tr.cut { opacity: .45; }
table.grid tr.drop-target td { background: var(--accent-soft-2); box-shadow: inset 0 2px 0 var(--accent), inset 0 -2px 0 var(--accent); }
table.grid tr.folder .nm { font-weight: 600; }
table.grid tr.unread .nm { font-weight: 700; }
table.grid tr.placeholder .nm { font-style: italic; color: var(--muted); }
.c-check { width: 30px; text-align: center; }
.c-idx { width: 1%; white-space: nowrap; font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.c-name { min-width: 220px; }
.c-num, .c-fmt { width: 1%; white-space: nowrap; text-align: right; color: var(--muted); font-size: 12.5px; }
.c-fmt { text-align: left; }
.c-date, .c-user { width: 1%; white-space: nowrap; color: var(--muted); font-size: 12.5px; }
.c-act { width: 34px; text-align: right; white-space: nowrap; }
table.grid tr .c-act .btn { opacity: 0; }
table.grid tr:hover .c-act .btn, table.grid tr.selected .c-act .btn { opacity: 1; }
.unread-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: 1px; }
.name-cell { display: flex; align-items: center; gap: 7px; min-width: 0; }
.name-cell .nm { overflow: hidden; text-overflow: ellipsis; display: flex; flex-direction: column; min-width: 0; }
.name-cell .nm > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.path { display: block; font-size: 11.5px; font-weight: 400; color: var(--muted); font-style: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.snippet { display: block; color: var(--muted); font-size: 12px; font-weight: 400; white-space: normal; }
.snippet mark { background: var(--accent-soft-2); color: inherit; padding: 0 1px; border-radius: 2px; }
.caret { width: 20px; height: 20px; display: grid; place-items: center; border: 0; background: none; padding: 0; cursor: pointer; color: var(--muted); border-radius: 4px; flex: none; }
.caret:hover { background: rgba(15, 30, 55, .07); }
.caret svg { width: 13px; height: 13px; transition: transform .12s; }
.caret.open svg { transform: rotate(90deg); }
.caret.none { visibility: hidden; }
.ficon { width: 24px; height: 24px; flex: none; border-radius: 5px; display: grid; place-items: center; font-size: 8.5px; font-weight: 700; color: #fff; letter-spacing: .02em; }
.ficon.folder { background: none; color: #e0a72c; }
.ficon.project { background: var(--accent); color: #fff; }
.ficon.project svg.icon { width: 15px; height: 15px; }
/* Progetti (primo livello): intestazioni senza numero, la numerazione riparte al loro interno. */
table.grid tr.project td { background: #f1f4f8; height: 42px; border-bottom-color: var(--line); }
table.grid tr.project .nm { font-size: 14.5px; font-weight: 700; }
table.grid tr.project.selected td { background: var(--accent-soft); }
.ficon.folder svg { width: 21px; height: 21px; fill: #f7cf6b; stroke: #d39b22; }
.ficon.folder.open svg { fill: #fbe3a1; }
.ficon.placeholder { background: none; color: var(--muted); }
.ficon.placeholder svg { width: 20px; height: 20px; }
.ficon.pdf { background: #d84a4a; }
.ficon.word { background: #3e63dd; }
.ficon.excel { background: #2b8a57; }
.ficon.ppt { background: #d0702c; }
.ficon.img { background: #8e4ec6; }
.ficon.other { background: #7b7a8c; }
.flag { color: var(--warn); display: inline-flex; }
.flag svg { width: 14px; height: 14px; fill: #f5c046; }
.bm-dots { display: inline-flex; gap: 3px; }
.bm { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.bm.group { border-radius: 2px; }
.bm-red { background: #e5484d; } .bm-orange { background: #f76b15; } .bm-yellow { background: #e9b200; }
.bm-green { background: #30a46c; } .bm-blue { background: #3e63dd; } .bm-purple { background: #8e4ec6; }
.empty-row td { height: auto; padding: 40px 16px !important; text-align: center; color: var(--muted); cursor: default; }
.result-head td { height: auto; padding: 8px 10px !important; background: #f8fafc; color: var(--muted); font-size: 13px; }
.trash-row { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border: 0; border-top: 1px solid var(--line); background: #f8fafc; color: var(--muted); cursor: pointer; text-align: left; }
.trash-row:hover { background: #f1f4f8; color: var(--text); }
.trash-row .count-pill { margin-left: 0; }

/* permessi */
.c-perm { width: 1%; white-space: nowrap; text-align: center; border-left: 1px solid #eef2f6; }
.c-perm.changed { background: #fff8e6 !important; }
.perm-head { font-size: 11.5px; color: var(--text); text-transform: none; letter-spacing: 0; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.perm-legend { display: flex; gap: 3px; justify-content: center; font-size: 10px; }
.perm-legend span { width: 22px; text-align: center; }
.perm-cell { display: inline-flex; align-items: center; gap: 3px; }
.perm-lvl { width: 22px; height: 22px; border-radius: 5px; border: 1px solid var(--line-2); background: #fff; color: var(--muted); font-size: 10.5px; font-weight: 700; cursor: pointer; padding: 0; }
.perm-lvl.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.perm-cell.inherited .perm-lvl.on { background: var(--accent-soft-2); border-color: var(--accent-soft-2); color: var(--accent); }
.perm-reset { width: 20px; height: 20px; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; display: grid; place-items: center; }
.perm-reset:hover { color: var(--accent); }
.perm-reset svg { width: 13px; height: 13px; }
.perm-reset-space { width: 20px; display: inline-block; }
table.grid.perm-mode tr.irow { cursor: default; }

/* --------------------------------------------------------------- visualizzatore */
.viewer-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #e6eaf0; user-select: none; -webkit-user-select: none; }
.vp-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.vp-title { min-width: 0; flex: 1; }
.vp-title b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.vp-title span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vp-tabs { display: flex; gap: 2px; padding: 2px; background: #eff3f7; border-radius: 8px; }
.vp-tab, .vp-icon { width: 32px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.vp-tab:hover, .vp-icon:hover { color: var(--accent); background: var(--accent-soft); }
.vp-tab.active { background: #fff; color: var(--accent); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.vp-body { flex: 1; display: flex; min-height: 0; }
.vp-thumbs { width: 112px; flex: none; overflow-y: auto; padding: 10px; background: #f2f5f8; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.thumb { position: relative; display: block; width: 100%; min-height: 60px; padding: 0; border: 2px solid transparent; border-radius: 4px; background: #fff; cursor: pointer; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.thumb img { display: block; width: 100%; pointer-events: none; }
.thumb span { position: absolute; bottom: 3px; right: 4px; font-size: 10px; background: rgba(15, 25, 40, .7); color: #fff; padding: 0 5px; border-radius: 6px; }
.thumb.active { border-color: var(--accent); }
.vp-stage { flex: 1; position: relative; min-width: 0; display: flex; }
.vp-pages { flex: 1; overflow: auto; padding: 20px 12px 90px; }
.viewer-page { position: relative; margin: 0 auto 18px; }
.page-inner { position: absolute; background: #fff; box-shadow: 0 2px 10px rgba(15, 30, 50, .18); transform-origin: center center; }
.page-inner img { display: block; width: 100%; height: 100%; pointer-events: none; -webkit-user-drag: none; }
.page-inner .ph { position: absolute; inset: 0; display: grid; place-items: center; color: #a5a2b8; }
.hl-layer { position: absolute; inset: 0; pointer-events: none; }
.hl { position: absolute; background: color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 2px; mix-blend-mode: multiply; }
.hl.current { background: rgba(255, 196, 0, .55); outline: 2px solid #f0a800; }
.viewer-page .pno { position: absolute; right: -30px; top: 2px; color: #9a97ad; font-size: 11px; }
.viewer-msg { margin: 60px auto; max-width: 440px; background: #fff; border-radius: 10px; padding: 28px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; box-shadow: var(--shadow); }
.vp-toolbar {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; align-items: center; gap: 2px; padding: 5px 8px;
  background: var(--ink); color: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); max-width: calc(100% - 24px); flex-wrap: wrap; justify-content: center;
}
.vt-btn { width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 7px; background: none; color: #d3dbe6; cursor: pointer; }
.vt-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.vt-sep { width: 1px; height: 20px; background: rgba(255, 255, 255, .18); margin: 0 4px; }
.vt-pages { font-size: 13px; color: #d3dbe6; white-space: nowrap; }
.vt-page { width: 42px; height: 26px; text-align: center; border-radius: 5px; border: 0; background: rgba(255, 255, 255, .14); color: #fff; }
.vt-zoom { font-size: 12px; min-width: 40px; text-align: center; color: #d3dbe6; }
.vt-searchbox { display: flex; align-items: center; gap: 2px; }
.vt-search { width: 170px; height: 26px; border-radius: 5px; border: 0; padding: 0 8px; background: rgba(255, 255, 255, .14); color: #fff; }
.vt-search::placeholder { color: #a9a4c4; }
.vt-count { font-size: 12px; color: #d3dbe6; min-width: 48px; text-align: center; white-space: nowrap; }
.vp-panel { width: 300px; flex: none; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); user-select: text; -webkit-user-select: text; }
.panel-title { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.panel-scroll { flex: 1; overflow-y: auto; padding: 12px 16px; }
.panel-scroll > * + * { margin-top: 10px; }
.panel-foot { padding: 12px 16px; border-top: 1px solid var(--line); }
.note { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }
.note.shared { border-color: var(--accent-soft-2); background: var(--accent-soft); }
.note-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-bottom: 4px; }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.qa-mini { display: block; width: 100%; text-align: left; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 9px 11px; cursor: pointer; }
.qa-mini:hover { border-color: var(--accent); }

/* --------------------------------------------------------------- menu e tendine */
.menu { position: fixed; z-index: 90; min-width: 220px; max-width: 340px; padding: 5px; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow-lg); }
.menu button { display: flex; width: 100%; align-items: center; gap: 9px; padding: 7px 10px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; text-align: left; font-size: 13.5px; }
.menu button:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.menu button:disabled { opacity: .45; cursor: default; }
.menu button.danger { color: var(--err); }
.menu button.danger:hover { background: var(--err-soft); color: var(--err); }
.menu .menu-label { flex: 1; }
.menu .menu-hint { color: var(--muted); font-size: 12px; }
.menu .sub-caret { width: 12px; height: 12px; color: var(--muted); }
.menu .icon-space { width: 16px; flex: none; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu-title { padding: 6px 10px 4px; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.menu-hint-block { padding: 6px 10px; font-size: 12px; color: var(--muted); max-width: 300px; }
.menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.dropdown { position: fixed; z-index: 85; width: 380px; max-height: 70vh; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); }
.dropdown.narrow { width: 220px; }
.dropdown-head { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.dropdown-body { overflow-y: auto; padding: 6px; }
.dropdown.narrow .dropdown-body { padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.dropdown-foot { padding: 8px 14px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.notif, .tray-item { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 9px 10px; border: 0; background: none; border-radius: 7px; text-align: left; cursor: pointer; }
.tray-item { cursor: default; align-items: center; }
.notif:hover { background: #f5f7fa; }
.notif.unread { background: var(--accent-soft); }
.notif-ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: #eef2f6; color: var(--accent); flex: none; }
.notif-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.filters-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; padding: 10px 10px 4px; }
.filter-group { display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.filter-title { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px; }
.filter-group .check input { margin-top: 2px; }

/* --------------------------------------------------------------- caricamenti */
.uploads { position: fixed; right: 16px; bottom: 16px; width: min(380px, calc(100vw - 32px)); max-height: 50vh; display: flex; flex-direction: column; background: var(--panel); border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 70; overflow: hidden; }
.uploads .head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--ink); color: #fff; }
.uploads .head .btn { color: #fff; }
.uploads .items { overflow: auto; padding: 6px 0; }
.uploads .item { padding: 6px 12px; font-size: 12.5px; }
.uploads .item .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ok-ico { color: var(--ok); }
.bar { height: 4px; background: var(--line); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.bar.done > i { background: var(--ok); }
.bar.fail > i { background: var(--err); }

/* --------------------------------------------------------------- Q&A */
.qa-layout { display: grid; grid-template-columns: minmax(320px, 400px) 1fr; height: 100%; min-height: 0; }
.qa-left { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); }
.qa-left-head { display: flex; align-items: center; gap: 6px; padding: 14px 14px 10px; }
.qa-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 14px 10px; border-bottom: 1px solid var(--line); }
.qa-tabs button { display: flex; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 3px 6px 3px 10px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.qa-tabs button:hover { border-color: var(--line-2); color: var(--ink-2); }
.qa-tabs button.active { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-soft-2); }
.qa-tabs .count-pill { margin-left: 0; height: 16px; min-width: 18px; font-size: 10.5px; }
.qa-tabs button.active .count-pill { background: var(--accent); color: #fff; }
.qa-search { padding: 10px 14px; }
.qa-list { flex: 1; overflow-y: auto; padding: 0 8px 12px; }
.qa-item { display: block; width: 100%; text-align: left; padding: 10px 12px; margin-bottom: 4px; border: 1px solid transparent; border-radius: 8px; background: none; cursor: pointer; }
.qa-item:hover { background: #f4f7fa; }
.qa-item.active { background: var(--accent-soft); border-color: var(--accent-soft-2); }
.qa-id { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.qa-subject { font-weight: 600; margin: 3px 0 1px; }
.qa-ref { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.qa-detail { overflow-y: auto; padding: 22px 26px 40px; min-height: 0; }
.qa-detail > * + * { margin-top: 16px; }
.qa-detail-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.qa-detail-head h2 { font-size: 19px; margin: 6px 0 4px; }
.qa-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); text-align: center; }
.qa-empty svg { width: 40px; height: 40px; color: var(--line-2); }
.qa-thread { display: flex; flex-direction: column; gap: 12px; max-width: 860px; }
.msg { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fff; }
.msg.answer { background: var(--accent-soft); border-color: var(--accent-soft-2); margin-left: 32px; }
.msg .meta { display: flex; gap: 10px; font-size: 12.5px; margin-bottom: 6px; }
.msg .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.qa-reply { max-width: 860px; }
.qa-reply > * + * { margin-top: 8px; }

/* Q&A: priorita', categorie, avvisi, tipi di messaggio */
.prio { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.prio .icon { width: 13px; height: 13px; }
.prio-high { color: var(--err); }
.prio-low { color: var(--muted); font-weight: 600; }
.chip { display: inline-flex; align-items: center; height: 19px; padding: 0 7px; border-radius: 4px; border: 1px solid var(--line-2); font-size: 11px; font-weight: 600; color: var(--ink-2); background: #fff; white-space: nowrap; }
.qa-ref .chip { flex: none; }
.qa-infos { padding: 0 14px 8px; display: flex; flex-direction: column; gap: 6px; }
.qa-info { display: flex; align-items: flex-start; gap: 8px; padding: 7px 10px; border-radius: 7px; background: var(--accent-soft); color: var(--ink-2); font-size: 12.5px; }
.qa-info .icon { width: 15px; height: 15px; flex: none; margin-top: 1px; color: var(--accent); }
.qa-info.warn { background: var(--warn-soft); }
.qa-info.warn .icon { color: var(--warn); }
.qa-detail > .qa-info { max-width: 860px; }
.qa-search > * + * { margin-top: 6px; }
.qa-search .row { flex-wrap: wrap; }
.qa-search .row .input.sm { flex: 1; min-width: 0; }
.qa-search .row .input.sm.full { flex-basis: 100%; }
.qa-experts { display: inline-flex; align-items: center; gap: 3px; margin-left: 8px; color: var(--accent); }
.qa-experts .icon { width: 13px; height: 13px; }
.qa-tools { gap: 6px; justify-content: flex-end; }
.qa-tools .input.sm { width: auto; max-width: 170px; }
.msg.question { border-left: 3px solid var(--line-2); }
.msg.followup { margin-left: 0; border-left: 3px solid var(--line-2); }
.msg.draft { margin-left: 32px; border: 1px dashed #e0b25c; background: #fffaf0; }
.msg.internal { margin-left: 32px; background: #fff8dd; border-color: #f0dc8c; }
.msg .meta { flex-wrap: wrap; align-items: center; }
.msg-actions { margin-top: 10px; }
.cat-row { display: flex; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--line); }

/* Verifica in due passaggi */
.auth-ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.auth-ico .icon { width: 24px; height: 24px; }
.code-input { font-family: var(--mono); font-size: 22px; letter-spacing: 6px; height: 46px; text-align: center; max-width: 220px; }
.muted-link { color: var(--muted); font-weight: 500; }
.twofa-step { display: flex; gap: 12px; align-items: flex-start; }
.twofa-step > div > * { display: block; }
.twofa-step > div > .row, .twofa-step > div > .copybox { display: flex; }
.twofa-step > div > * + * { margin-top: 6px; }
.step-n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; flex: none; }
.twofa-step > div > .twofa-qr { width: fit-content; }
.twofa-qr { padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.twofa-qr img { display: block; width: 180px; height: 180px; image-rendering: pixelated; }
.secret { font-family: var(--mono); font-size: 13px; padding: 6px 10px; border-radius: 6px; background: #f1f4f8; overflow-wrap: anywhere; }
.copybox .secret { flex: 1; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 14px; padding: 12px 14px; border: 1px dashed var(--line-2); border-radius: 8px; background: #f8fafc; }
.recovery-codes code { font-family: var(--mono); font-size: 14px; letter-spacing: .5px; }
.ok-box { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 8px; background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.ok-box .icon { width: 16px; height: 16px; }
.twofa-mark { display: inline-flex; margin-left: 5px; color: var(--ok); vertical-align: -2px; }
.twofa-mark .icon { width: 13px; height: 13px; }

/* Scheda del gruppo: sezioni */
.card-section { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 18px 0 10px; }
.card-section:first-child { margin-top: 0; }
.input.num { width: 90px; }
.group-card textarea.input { height: auto; padding: 8px 10px; margin-top: 6px; }
.ref-box { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 13px; }

/* --------------------------------------------------------------- utenti */
.split-page { display: grid; grid-template-columns: 260px 1fr; height: 100%; min-height: 0; }
.side-list { background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; padding: 10px 8px; }
.side-head { display: flex; align-items: center; padding: 4px 8px 10px; }
.side-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 7px; color: var(--text); text-decoration: none; }
.side-item:hover { background: #f5f7fa; text-decoration: none; }
.side-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-sep { height: 1px; background: var(--line); margin: 8px 6px; }
.side-content { overflow-y: auto; padding: 22px 24px 40px; min-width: 0; }
.side-content > * + * { margin-top: 16px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 28px; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.s-online { background: #30a46c; }
.s-offline { background: #b5b3c2; }
.s-invited { background: #e9b200; }
.s-pending { background: transparent; box-shadow: inset 0 0 0 2px #e9b200; }
.s-blocked { background: #e5484d; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-weight: 600; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 9px 12px; border-bottom: 1px solid var(--line); background: #f8fafc; }
table.list td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list .c-act .btn { opacity: 1; }
.table-scroll { overflow-x: auto; }

/* --------------------------------------------------------------- report */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.stat { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 21px; font-weight: 700; }
.stat span { color: var(--muted); font-size: 12.5px; }
.stat-ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.chart { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.bar-views, .sw-views { fill: var(--accent); background: var(--accent); }
.bar-dl, .sw-dl { fill: #e9a23b; background: #e9a23b; }
.bar-login, .sw-login { fill: #8a97a8; background: #8a97a8; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.subtabs a { padding: 8px 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; }
.subtabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { min-width: 150px; }
.meter { display: inline-block; width: 60px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; vertical-align: middle; margin-right: 6px; }
.meter i { display: block; height: 100%; background: var(--accent); }
.logo-preview { height: 34px; max-width: 160px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; padding: 3px; background: #fff; }

/* --------------------------------------------------------------- modali e notifiche */
.modal-back { position: fixed; inset: 0; background: rgba(15, 30, 50, .45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--panel); border-radius: 12px; box-shadow: var(--shadow-lg); }
.modal.wide { max-width: 780px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 0 20px; }
.modal-body { padding: 16px 20px; overflow: auto; }
.modal-body > * + * { margin-top: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; }
.modal-foot.spread { justify-content: flex-start; }
.copybox { display: flex; gap: 6px; }
.copybox input { font-size: 12px; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 22px; }
.help-grid > * + * { margin-top: 0 !important; }
.help-item { display: flex; gap: 12px; }
.help-item p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.help-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
#toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 120; align-items: center; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-lg); max-width: 90vw; }
.toast.err { background: var(--err); }

/* --------------------------------------------------------------- elementi solo per telefono */
.head-logo, .head-account, .qa-back, .tab-ico { display: none; }
.btn-label { white-space: nowrap; }

/* --------------------------------------------------------------- tablet e finestre strette */
@media (max-width: 1100px) {
  .docs-layout.with-viewer { grid-template-columns: 1fr; }
  .docs-layout.with-viewer .index-pane { display: none; }
  .vp-panel { position: absolute; right: 0; top: 0; bottom: 0; z-index: 5; box-shadow: var(--shadow-lg); }
  .vp-body { position: relative; }
}
@media (max-width: 900px) {
  .project-head { flex-wrap: wrap; gap: 6px 16px; padding: 0 12px; }
  .project-name { max-width: 60vw; }
  .tabs-nav { order: 3; width: 100%; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 28px; min-height: 200px; }
  .qa-layout, .split-page { grid-template-columns: 1fr; }
  .qa-left, .side-list { max-height: 40vh; }
  .c-num, .c-fmt, .c-date, .c-user, .hide-sm { display: none; }
  .two-col, .settings-grid, .help-grid, .filters-grid { grid-template-columns: 1fr; }
  .page, .side-content, .qa-detail { padding: 16px; }
  .vp-thumbs, .vp-toolbar [aria-label="Miniature"] { display: none; }
  .viewer-page .pno { display: none; }
}

/* --------------------------------------------------------------- telefono */
/* Riferimenti: Material Design 3 (barra superiore 56 px, righe di elenco >= 56 px con margini di 16 px,
   titoli 16 px e testo secondario 14 px, barra di navigazione in basso con indicatore della sezione attiva),
   navigazione "a cartelle" con percorso e indietro al posto dell'albero, tabelle trasformate in schede,
   azioni in un pannello che sale dal basso. */
.fab, .m-head, .m-list { display: none; }
.chip.project { display: inline-flex; align-items: center; gap: 4px; }
.chip.project svg { width: 14px; height: 14px; }
.chip.project.closed { color: var(--muted); }
.closing-date { padding-left: 32px; max-width: 240px; }
.filters-box > summary { display: none; }
details.filters-box { display: flex; }
@media (max-width: 760px) {
  :root { --nav-h: 64px; --gutter: 16px; }
  body { font-size: 15px; }

  /* Barra superiore: logo, nome della data room, notifiche, download, profilo. */
  .shell { grid-template-columns: 1fr; grid-template-rows: 1fr; }
  .rail { display: none; }
  .project-head { flex-wrap: nowrap; min-height: 56px; padding: 0 4px 0 var(--gutter); gap: 8px; align-items: center; box-shadow: 0 1px 0 var(--line); border-bottom: 0; }
  .project-title { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; padding: 6px 0; min-width: 0; }
  .head-logo { display: grid; place-items: center; grid-row: span 2; width: 36px; height: 36px; }
  .head-logo .brand-mark.sm { width: 34px; height: 34px; border-radius: 9px; }
  .head-logo .brand-logo.sm { width: 36px; height: 32px; }
  .project-name { font-size: 17px; max-width: none; line-height: 1.25; }
  .project-sub { font-size: 12.5px; line-height: 1.2; }
  .head-tools { gap: 0; }
  .head-account { display: grid; }

  /* Navigazione in basso (Material 3): icona con "pillola" sulla sezione attiva, etichetta sotto. */
  .tabs-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; order: 0; width: auto;
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; align-items: stretch;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding: 0 4px env(safe-area-inset-bottom);
    background: #f8fafc; border-top: 1px solid var(--line); overflow: visible;
  }
  .tabs-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 0 2px;
    border: 0; font-size: 12px; font-weight: 600; color: var(--muted); min-width: 0; }
  .tabs-nav a.active { color: var(--text); border: 0; background: none; }
  .tabs-nav svg.tab-ico { display: block; width: 56px; height: 30px; padding: 4px 16px; border-radius: 15px; transition: background .15s; }
  .tabs-nav a.active .tab-ico { background: var(--accent-soft-2); color: var(--accent); }
  .tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .main { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }

  /* Documento aperto: tutto lo schermo al documento (niente barra superiore e navigazione). */
  body.viewing .project-head, body.viewing .tabs-nav { display: none; }
  body.viewing .main { padding-bottom: 0; }
  .vp-head { padding: 6px 4px 6px 12px; gap: 6px; min-height: 56px; }
  .vp-head > .ficon { display: none; }
  .vp-title b { font-size: 15px; }
  .vp-full { display: none; }
  .vp-tabs { background: none; padding: 0; }
  .vp-toolbar { flex-wrap: nowrap; overflow-x: auto; max-width: calc(100vw - 16px); justify-content: flex-start; bottom: calc(12px + env(safe-area-inset-bottom)); border-radius: 16px; }
  .vp-panel { width: 100%; }

  #toasts { bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); width: calc(100% - 24px); }
  .uploads { right: 8px; left: 8px; width: auto; bottom: calc(var(--nav-h) + 8px + env(safe-area-inset-bottom)); }
  .dropdown { width: auto; left: 8px !important; right: 8px; max-width: none; max-height: calc(100vh - 140px); }

  /* Menu delle azioni come pannello che sale dal basso, con voci alte e leggibili. */
  .menu { left: 0 !important; right: 0; top: auto !important; bottom: 0; min-width: 0; max-width: none; max-height: 75vh; overflow-y: auto;
    border-radius: 18px 18px 0 0; padding: 8px 8px calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 40px rgba(15, 30, 50, .25); z-index: 95; }
  .menu::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 2px auto 8px; }
  .menu-backdrop { position: fixed; inset: 0; z-index: 94; background: rgba(15, 30, 50, .35); }
  .menu button { padding: 12px 14px; font-size: 16px; gap: 14px; border-radius: 10px; }
  .menu button svg.icon { width: 20px; height: 20px; }
  .menu .who { padding: 8px 14px 12px; }

  /* Indice: ricerca e filtri in una riga, elenco a cartelle al posto della tabella. */
  .index-toolbar { gap: 6px; padding: 8px 8px 8px var(--gutter); border-bottom: 0; flex-wrap: nowrap; }
  .search-box { flex: 1 1 auto; min-width: 0; }
  .search-box .input { border-radius: 22px; background: #f1f4f8; border-color: transparent; padding-left: 36px; }
  .search-box svg { left: 12px; top: 50%; transform: translateY(-50%); }
  .index-toolbar .input.mode, .index-toolbar .tb-create, .index-toolbar [aria-label="Colonne"], .index-toolbar [aria-label="Permessi"],
  .index-toolbar [aria-label="Visualizza come un gruppo"], .index-toolbar [aria-label^="Esporta indice"], .index-toolbar .spacer { display: none; }
  .index-toolbar .btn:not(.primary) .btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .index-toolbar .btn:not(.primary):not(.icon-only) { width: 44px; padding: 0; justify-content: center; position: relative; }
  .grid-wrap { padding-bottom: 88px; }
  .m-head { display: flex; align-items: center; gap: 4px; padding: 6px 4px 10px var(--gutter); position: sticky; top: 0; z-index: 3; background: var(--panel); border-bottom: 1px solid var(--line); }
  .m-back { display: grid; place-items: center; width: 44px; height: 44px; margin-left: -12px; border-radius: 22px; color: var(--text); flex: none; }
  .m-back:active { background: var(--accent-soft); }
  .m-back svg.icon { width: 22px; height: 22px; }
  .m-head-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .m-head-text b { font-size: 18px; line-height: 1.3; overflow-wrap: anywhere; }
  .m-head-text span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .m-list { display: block; list-style: none; margin: 0; padding: 0; }
  .m-item { display: flex; align-items: center; gap: 0; padding-right: 4px; border-bottom: 1px solid #eef2f6; }
  .m-item.cut { opacity: .45; }
  .m-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; padding: 12px 4px 12px var(--gutter); min-height: 64px; color: var(--text); text-decoration: none; }
  .m-link:active { background: #f1f4f8; }
  .m-link:hover { text-decoration: none; }
  .m-idx { color: var(--accent); font-weight: 700; margin-right: 6px; font-variant-numeric: tabular-nums; }
  .m-link .ficon { width: 40px; height: 40px; border-radius: 10px; font-size: 10px; }
  .m-link .ficon svg.icon { width: 22px; height: 22px; }
  .m-link .ficon.folder { background: #fdf3df; }
  .m-link .ficon.folder svg.icon { width: 24px; height: 24px; }
  .m-link .ficon.placeholder { background: #f1f4f8; }
  .m-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  .m-title { font-size: 16px; line-height: 1.3; font-weight: 500; overflow-wrap: anywhere;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .m-item.folder .m-title { font-weight: 600; }
  .m-item.project .m-title { font-weight: 700; font-size: 17px; }
  .m-item.unread .m-title { font-weight: 700; }
  .m-item.placeholder .m-title { font-style: italic; color: var(--muted); }
  .m-title .flag, .m-title .bm-dots { margin-left: 6px; vertical-align: -2px; }
  .m-meta { font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .m-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
  .m-main .snippet { font-size: 13px; }
  .m-chev { width: 18px; height: 18px; color: var(--line-2); flex: none; }
  .m-item.folder .m-link { padding-right: 0; }
  .m-empty { padding: 48px 24px; text-align: center; color: var(--muted); }
  .fab { display: grid; place-items: center; position: fixed; right: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 55;
    width: 56px; height: 56px; border-radius: 16px; border: 0; background: var(--accent); color: #fff; box-shadow: 0 6px 20px rgba(15, 30, 50, .3); cursor: pointer; }
  .fab svg.icon { width: 26px; height: 26px; stroke-width: 2.2; }
  .fab:active { background: var(--accent-strong); }
  .trash-row { padding: 14px var(--gutter); }

  /* Q&A: elenco oppure domanda, uno alla volta. */
  .qa-left { max-height: none; border-right: 0; }
  .qa-left-head { padding: 14px var(--gutter) 8px; }
  .qa-left-head h2 { font-size: 20px; }
  .qa-tabs, .qa-search, .qa-infos { padding-left: var(--gutter); padding-right: var(--gutter); }
  .qa-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .qa-tabs button { flex: none; }
  .qa-list { padding: 0 8px 24px; }
  .qa-item { padding: 12px 10px; border-bottom: 1px solid #eef2f6; border-radius: 0; }
  .qa-subject { font-size: 16px; }
  .qa-layout { height: auto; min-height: 100%; }
  .qa-layout.has-detail .qa-left { display: none; }
  .qa-layout:not(.has-detail) .qa-detail { display: none; }
  .qa-back { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; min-height: 44px; }
  .qa-detail { padding: 4px var(--gutter) 24px; }
  .qa-detail-head { flex-direction: column; gap: 10px; }
  .qa-detail-head h2 { font-size: 20px; }
  .qa-tools { justify-content: flex-start; }
  .msg { padding: 12px; }
  .msg.answer, .msg.draft, .msg.internal { margin-left: 10px; }

  /* Utenti: i gruppi diventano una fila di "chip" che scorre. */
  .split-page { grid-template-rows: auto 1fr; height: auto; }
  .side-list { display: flex; gap: 8px; max-height: none; overflow-x: auto; overflow-y: hidden; padding: 10px var(--gutter); border-right: 0; border-bottom: 1px solid var(--line); scrollbar-width: none; }
  .side-list .side-head { padding: 0; flex: none; }
  .side-list .side-head b, .side-list .side-sep, .side-list .pad { display: none; }
  .side-item { flex: none; border: 1px solid var(--line-2); border-radius: 20px; padding: 6px 14px; white-space: nowrap; min-height: 40px; }
  .side-content { padding: 12px; overflow: visible; }
  .side-content .legend { display: none; }

  /* Tabelle come schede: una scheda per riga, ogni valore con la sua etichetta. */
  .table-scroll { overflow: visible; }
  table.stack-sm, table.stack-sm tbody { display: block; width: 100%; }
  table.stack-sm thead { display: none; }
  table.stack-sm tr { display: block; position: relative; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  table.stack-sm td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; border: 0; min-height: 32px; text-align: right; }
  table.stack-sm td::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; flex: none; }
  table.stack-sm td:first-child { display: block; text-align: left; padding: 0 44px 6px 0; }
  table.stack-sm td:first-child::before, table.stack-sm td.c-act::before, table.stack-sm td[colspan]::before { display: none; }
  table.stack-sm td.c-act { position: absolute; top: 6px; right: 4px; min-height: 0; padding: 0; }
  table.stack-sm td.c-check { position: absolute; top: 12px; left: 14px; }
  table.stack-sm td.c-check + td { padding-left: 36px; }
  table.stack-sm td .input.sm { width: auto; max-width: 60%; }
  table.stack-sm td.empty, table.stack-sm td[colspan] { display: block; text-align: center; }
  table.stack-sm td:empty { display: none; }
  table.stack-sm td a { display: inline-block; padding: 8px 0; }
  table.stack-sm .audit-row td:first-child { color: var(--muted); }

  /* Report e impostazioni. */
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 12px; gap: 10px; }
  .stat-ico { width: 32px; height: 32px; }
  .subtabs { overflow-x: auto; scrollbar-width: none; }
  .subtabs a { white-space: nowrap; min-height: 44px; display: inline-flex; align-items: center; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters-box { display: block; }
  .filters-box > summary { display: flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 600; cursor: pointer; }
  .filters-box[open] > summary { margin-bottom: 8px; }
  .filters-box .spacer { display: none; }
  svg.chart .axis { font-size: 12px; }
  .filters .field { min-width: 0; }
  .panel-head { padding: 10px 12px; }
  .panel-body { padding: 12px; }
  .page { padding: 12px 12px 24px; }

  /* Finestre a tutta larghezza, dal basso. */
  .modal-back { padding: 0; align-items: end; }
  .modal, .modal.wide { max-width: none; border-radius: 18px 18px 0 0; max-height: calc(100vh - 24px); }
  .modal-head { padding: 16px 8px 0 var(--gutter); }
  .modal-body { padding: 14px var(--gutter); }
  .modal-foot { padding: 10px var(--gutter) calc(14px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 auto; }
  .auth-main { padding: 20px var(--gutter) 32px; }
}

/* --------------------------------------------------------------- schermi touch */
/* Aree toccabili di almeno 44 px (Apple, Material, WCAG 2.5.5); campi a 16 px per evitare lo zoom su iPhone. */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn.sm { height: 40px; min-height: 40px; padding: 0 12px; }
  .btn.icon-only, .btn.sm.icon-only { width: 44px; min-width: 44px; height: 44px; }
  .head-btn { width: 44px; height: 44px; }
  .input, select.input { height: 44px; font-size: 16px; }
  .input.sm { height: 40px; font-size: 16px; }
  textarea.input { font-size: 16px; }
  table.grid td { height: 50px; }
  .c-check input, .check input, input[type=checkbox]:not(.switch) { width: 24px; height: 24px; }
  .qa-ref a { display: inline-block; padding: 6px 0; }
  .c-check { width: 40px; }
  .caret { width: 36px; height: 36px; }
  .switch { width: 46px; height: 28px; border-radius: 14px; }
  .switch::after { width: 22px; height: 22px; }
  .switch:checked::after { left: 22px; }
  .menu button { min-height: 44px; font-size: 15px; }
  .qa-item, .notif, .side-item { min-height: 44px; }
  .qa-tabs button { min-height: 36px; padding: 6px 8px 6px 12px; }
  .vp-toolbar .btn, .vp-toolbar button { min-width: 40px; min-height: 40px; }
}
/* Senza mouse non esiste il passaggio sopra: le azioni delle righe restano sempre visibili. */
@media (hover: none) {
  table.grid tr .c-act .btn { opacity: 1; }
}
@media print {
  body * { display: none !important; }
  body::after { content: "La stampa diretta non e' consentita: usa il comando Stampa del visualizzatore."; display: block !important; padding: 40px; font-size: 18px; }
}
