/* vlan.microwifi.it — foglio di stile unico. Nessuno stile inline nel markup: tutto passa da queste classi.
   (Solo la geometria della griglia, calcolata in JavaScript, usa le proprietà di stile dell'elemento.) */
:root {
  --bg: #f9fbfd;
  --surface: #ffffff;
  --toolbar: #edf2fa;
  --line: #dadce0;
  --line-strong: #c0c4cc;
  --text: #1f1f1f;
  --muted: #5f6368;
  --accent: #1a73e8;
  --accent-weak: #d3e3fd;
  --danger: #d93025;
  --ok: #188038;
  --radius: 8px;
  --shadow: 0 2px 6px rgba(60, 64, 67, .25);
  font-family: Roboto, "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 14px; overflow: hidden; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- login ---------- */
.login { height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 32px 28px; box-shadow: var(--shadow); }
.login-logo { width: 52px; height: 52px; border-radius: 14px; background: var(--ok); color: #fff; display: grid; place-items: center; font-size: 24px; margin-bottom: 14px; }
.login-card h1 { font-size: 22px; font-weight: 500; margin: 0 0 4px; }
.login-sub { color: var(--muted); margin: 0 0 20px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); }
.field input:focus, .field select:focus { border-color: var(--accent); outline: 2px solid var(--accent-weak); }
.form-error { color: var(--danger); margin: 0 0 12px; font-size: 13px; }

/* ---------- pulsanti ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 16px; border-radius: 18px; border: 1px solid var(--line-strong); background: var(--surface); }
.btn:hover { background: #f1f3f4; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #1765cc; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b3261e; }
.btn-ghost { border-color: transparent; background: transparent; height: 32px; padding: 0 12px; border-radius: 16px; }
.btn-ghost:hover { background: rgba(60, 64, 67, .08); }
.btn-block { width: 100%; justify-content: center; }
.btn-small { height: 28px; padding: 0 10px; font-size: 13px; }

/* ---------- struttura ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 6px; height: 52px; padding: 0 12px 0 16px; flex: none; white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 500; }
.brand { min-width: 0; flex: 0 1 auto; }
.brand #docTitle { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.topbar > .btn, .topbar > .user-chip, .topbar > .save-status { flex: none; }
.brand .fa-table-cells { color: var(--ok); font-size: 24px; }
#docTitle.is-editable { cursor: text; }
.title-input { font: inherit; width: 240px; max-width: 50vw; height: 32px; padding: 0 8px; border: 1px solid var(--accent); border-radius: 6px; background: var(--surface); }
.topbar-spacer, .tabs-spacer { flex: 1; }
.save-status { margin-left: 14px; color: var(--muted); font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; }
.save-status.is-error { color: var(--danger); }
.user-chip { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px 0 4px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.user-chip:hover { background: #f1f3f4; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 500; text-transform: uppercase; }
.user-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; margin: 0 12px 6px; padding: 4px 10px; min-height: 40px; background: var(--toolbar); border-radius: 24px; flex: none; }
.tb { position: relative; display: inline-grid; place-items: center; grid-auto-flow: column; gap: 2px; min-width: 30px; height: 30px; padding: 0 6px; border: 0; border-radius: 6px; background: transparent; color: #444746; font-size: 14px; }
.tb:hover { background: rgba(31, 31, 31, .08); }
.tb.is-on { background: var(--accent-weak); color: #0b57d0; }
.tb:disabled { opacity: .35; cursor: default; background: transparent; }
.tb-caret { font-size: 9px; }
.tsep { width: 1px; height: 20px; background: var(--line-strong); margin: 0 6px; }
.tsel { height: 30px; border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 0 4px; }
.tsel:hover { background: rgba(31, 31, 31, .08); }
.tb-color input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.tb-color { display: inline-block; text-align: center; line-height: 28px; }
.tb .swatch { position: absolute; left: 6px; right: 14px; bottom: 3px; height: 3px; border-radius: 1px; background: currentColor; color: transparent; }

.formulabar { display: flex; align-items: center; height: 28px; margin: 0 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); flex: none; }
.namebox { width: 96px; height: 100%; border: 0; border-right: 1px solid var(--line); padding: 0 10px; text-align: left; background: transparent; }
.fx { width: 34px; text-align: center; color: var(--muted); font-size: 13px; }
.fx em { font-family: "Times New Roman", serif; }
.formula-input { flex: 1; height: 100%; border: 0; padding: 0 8px; background: transparent; }
.formula-input:focus { outline: none; box-shadow: inset 0 -2px 0 var(--accent); }

.gridbox { position: relative; flex: 1; min-height: 0; margin: 0 12px; background: var(--surface); border: 1px solid var(--line); border-bottom: 0; overflow: hidden; }
.gridwrap { position: absolute; inset: 0; overflow: auto; outline: none; }
.gridwrap canvas { position: sticky; top: 0; left: 0; display: block; }
.sizer { position: absolute; top: 0; left: 0; pointer-events: none; }
.cell-editor { position: absolute; z-index: 5; margin: 0; padding: 2px 3px; border: 2px solid var(--accent); border-radius: 0; background: var(--surface); resize: none; overflow: hidden; outline: none; line-height: 1.25; white-space: pre; box-shadow: 0 2px 6px rgba(60, 64, 67, .3); font-family: Arial, Helvetica, sans-serif; }

.tabsbar { display: flex; align-items: center; height: 40px; padding: 0 12px; background: var(--bg); flex: none; border-top: 1px solid var(--line); }
.tab-add { width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: #444746; margin-right: 6px; flex: none; }
.tab-add:hover { background: rgba(31, 31, 31, .08); }
.tabs { display: flex; align-items: stretch; height: 100%; overflow-x: auto; scrollbar-width: thin; }
.tab { display: inline-flex; align-items: center; gap: 6px; height: 100%; padding: 0 16px; border: 0; background: transparent; color: #444746; font-weight: 500; white-space: nowrap; border-bottom: 3px solid transparent; }
.tab:hover { background: rgba(31, 31, 31, .06); }
.tab.is-active { background: var(--accent-weak); color: #0b57d0; border-bottom-color: var(--accent); }
.tab-caret { font-size: 10px; opacity: .7; padding: 4px; border-radius: 50%; }
.tab-caret:hover { background: rgba(31, 31, 31, .12); }
.sel-info { color: var(--muted); font-size: 12.5px; padding-left: 12px; white-space: nowrap; }

/* ---------- menu, dialoghi, avvisi ---------- */
.menu { position: fixed; z-index: 50; min-width: 200px; padding: 6px 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.menu button { display: flex; align-items: center; gap: 12px; width: 100%; height: 34px; padding: 0 16px; border: 0; background: transparent; text-align: left; }
.menu button:hover:not(:disabled) { background: #f1f3f4; }
.menu button:disabled { opacity: .4; cursor: default; }
.menu button.is-danger { color: var(--danger); }
.menu i { width: 16px; text-align: center; color: var(--muted); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.menu-head { padding: 6px 16px 2px; font-size: 11px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.menu-note { padding: 4px 16px 2px; font-size: 11px; color: var(--muted); }
.hint.search-hint { margin: 2px 0 14px; }
.search-form { display: flex; gap: 8px; margin-bottom: 14px; }
.search-form input[type="search"] { flex: 1; min-width: 0; height: 36px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 6px; }
.search-opt { display: block; margin-bottom: 16px; font-size: 13px; color: var(--muted); }
.search-sum { margin: 4px 0 8px; font-weight: 500; }
.search-field { color: var(--muted); }
.filter-pop { position: fixed; z-index: 55; width: 280px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); font-size: 13px; }
.filter-title { font-weight: 500; font-size: 14px; }
.filter-pop .hint { margin: 2px 0 10px; }
.filter-pop input[type="search"] { width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 6px; }
.filter-sub { margin: 12px 0 4px; color: var(--muted); font-size: 12px; }
.filter-row { display: flex; align-items: center; gap: 6px; padding: 3px 0; cursor: pointer; }
.filter-count { margin: 12px 0 8px; font-weight: 500; }
.stats h3 { margin: 18px 0 8px; font-size: 14px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.stats h3:first-child { margin-top: 0; }
.stat-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; }
.stat-title { font-weight: 500; margin-bottom: 4px; }
.stat-line { font-size: 13px; color: var(--muted); margin: 2px 0; }
.stat-bars { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.stat-bar { display: grid; grid-template-columns: 18px minmax(120px, 220px) 1fr 60px; align-items: center; gap: 8px; font-size: 13px; }
.stat-bar .legend-chip { width: 14px; height: 14px; border-radius: 3px; }
.stat-track { height: 10px; background: #eceff1; border-radius: 5px; overflow: hidden; }
.stat-fill { display: block; height: 100%; border-radius: 5px; }
.stat-n { text-align: right; font-variant-numeric: tabular-nums; }
.stat-days { display: flex; align-items: flex-end; gap: 6px; height: 84px; margin-top: 8px; }
.stat-day { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.stat-daybar { width: 100%; max-width: 28px; background: var(--accent); border-radius: 3px 3px 0 0; }
.stat-daylabel { font-size: 10px; color: var(--muted); margin-top: 3px; }
#printArea { display: none; }
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body > *:not(#printArea) { display: none !important; }
  html, body { background: #fff !important; height: auto !important; overflow: visible !important; }
  #printArea { display: block; color: #000; font-family: Arial, sans-serif; }
  #printArea * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #printArea h1 { font-size: 14pt; margin: 0 0 2pt; }
  #printArea .print-sub { font-size: 8pt; color: #555; margin: 0 0 8pt; }
  .print-table { border-collapse: collapse; table-layout: fixed; font-size: 8pt; }
  .print-table th, .print-table td { border: 1px solid #888; padding: 1px 3px; overflow: hidden; word-break: break-word; vertical-align: top; }
  .print-table th { background: #eee; color: #444; font-weight: 400; text-align: center; }
  .print-table thead { display: table-header-group; }
  .print-table tr { break-inside: avoid; }
  .print-legend { margin-top: 10pt; font-size: 8pt; }
  .print-chip { display: inline-block; width: 9pt; height: 9pt; border: 1px solid #555; margin: 0 4pt 0 6pt; vertical-align: -1pt; }
}
.info-form .field { margin-bottom: 10px; }
.info-row { display: grid; grid-template-columns: 3fr 2fr; gap: 12px; }
.info-row.is-equal { grid-template-columns: 1fr 1fr; }
@media (max-width: 480px) { .info-row, .info-row.is-equal { grid-template-columns: 1fr; gap: 0; } }
.info-sep { border: 0; border-top: 1px solid var(--line); margin: 14px 0 12px; }
.info-line { display: flex; align-items: center; gap: 6px; }
.info-line.is-multi { align-items: flex-start; }
.info-line input, .info-line textarea { flex: 1; min-width: 0; }
.copy-btn { flex: none; width: 36px; height: 36px; color: var(--muted); }
.copy-btn:hover:not(:disabled) { color: var(--accent); }
.copy-helper { position: fixed; left: -9999px; top: 0; opacity: 0; }
.info-tip-sep { grid-column: 1 / -1; border-top: 1px solid var(--line); margin: 3px 0; }
.info-form textarea { width: 100%; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); font: inherit; resize: vertical; }
.info-tip { position: fixed; z-index: 45; max-width: 340px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); font-size: 13px; pointer-events: none; }
.info-tip dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }
.info-tip dt { color: var(--muted); }
.info-tip dd { margin: 0; word-break: break-word; white-space: pre-wrap; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; }

dialog.modal { padding: 0; border: 0; border-radius: 16px; box-shadow: 0 8px 28px rgba(0, 0, 0, .3); max-width: calc(100vw - 24px); max-height: calc(100vh - 24px); color: var(--text); background: var(--surface); }
dialog.modal::backdrop { background: rgba(32, 33, 36, .5); }
.modal-card { display: flex; flex-direction: column; max-height: calc(100vh - 24px); }
.modal-head { display: flex; align-items: center; padding: 18px 24px 8px; }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 500; flex: 1; }
.modal-x { border: 0; background: transparent; width: 32px; height: 32px; border-radius: 50%; color: var(--muted); }
.modal-x:hover { background: #f1f3f4; }
.modal-body { padding: 8px 24px 16px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 24px 20px; }
.modal-msg { margin: 0 0 8px; line-height: 1.45; }
.w-sm { width: 420px; }
.w-md { width: 640px; }
.w-lg { width: min(1180px, calc(100vw - 24px)); }

.toasts { position: fixed; left: 16px; bottom: 56px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { max-width: min(420px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 6px; background: #323232; color: #fff; box-shadow: var(--shadow); }
.toast.is-error { background: var(--danger); }

/* ---------- tabelle (utenti, registro) ---------- */
.dtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.dtable th { position: sticky; top: 0; z-index: 1; text-align: left; font-weight: 500; color: var(--muted); background: var(--surface); padding: 8px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.dtable td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.dtable tr:hover td { background: #f8f9fa; }
.dtable .clip { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.dtable .cut { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dtable .num { text-align: right; white-space: nowrap; }
.dtable .nowrap { white-space: nowrap; }
.dtable select, .dtable input[type="text"] { height: 30px; border: 1px solid var(--line-strong); border-radius: 6px; padding: 0 6px; background: var(--surface); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; background: #f1f3f4; font-size: 12px; white-space: nowrap; }
.tag.t-login { background: #e6f4ea; color: #137333; }
.tag.t-fail { background: #fce8e6; color: var(--danger); }
.tag.t-cell { background: #e8f0fe; color: #1967d2; }
.tag.t-struct { background: #fef7e0; color: #b06000; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; align-items: end; margin-bottom: 12px; }
.filters .field { margin: 0; }
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding-top: 10px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; align-items: end; padding: 14px 0 4px; border-top: 1px solid var(--line); margin-top: 14px; }
.form-grid .field { margin: 0; }
.check-row { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; font-size: 13px; }
.form-grid .check-row { grid-column: 1 / -1; margin: 0; }
.modal-x[hidden] { display: none; }
.hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; }
.diff-old { color: var(--danger); }
.diff-new { color: var(--ok); }

@media (max-width: 1100px) {
  .topbar .btn span { display: none; }
  .btn-ghost { padding: 0 10px; }
}
@media (max-width: 760px) {
  .user-name, .save-status, .online-label { display: none; }
  .toolbar { border-radius: 12px; }
  .w-sm, .w-md { width: calc(100vw - 24px); }
}

/* ---------- utenti collegati, legenda, menu con colore ---------- */
.online { display: flex; align-items: center; gap: 4px; margin-right: 10px; }
.chip { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 500; text-transform: uppercase; border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--line); cursor: default; }
.chip.is-more { background: #80868b; font-size: 11px; }
.online-label { color: var(--muted); font-size: 12px; margin-right: 4px; }
.menu-dot { width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(0, 0, 0, .25); flex: none; }
.menu-dot.is-none { background: repeating-linear-gradient(45deg, #fff, #fff 3px, #e0e0e0 3px, #e0e0e0 5px); }
.legend-list { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 8px; }
.legend-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.legend-chip { width: 28px; height: 28px; border-radius: 6px; border: 1px solid rgba(0, 0, 0, .25); flex: none; }
.legend-text { flex: 1; word-break: break-word; }
.legend-sep { height: 1px; background: var(--line-strong); margin: 4px 0; }
.legend-edit .icon-btn.is-on { color: var(--accent); background: var(--accent-weak); }
.legend-edit { display: grid; grid-template-columns: 44px 1fr auto auto auto auto; gap: 6px; align-items: center; margin-bottom: 8px; }
.legend-edit input[type="color"] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); }
.legend-edit input[type="text"] { height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 6px; min-width: 0; }
.icon-btn { width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); }
.icon-btn:hover:not(:disabled) { background: #f1f3f4; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.color-tag { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.color-tag i { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .25); display: inline-block; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); text-decoration: none; font-weight: 500; }
.link-btn:hover { text-decoration: underline; }
.note { background: #e8f0fe; color: #174ea6; border-radius: 8px; padding: 10px 14px; margin: 0 0 12px; font-size: 13px; line-height: 1.45; }
.tag.t-keep { background: #e6f4ea; color: #137333; }
.tag.t-old { background: #fef7e0; color: #b06000; }
.modal-body form > .hint { margin: 0 0 12px; }

/* Telefoni e schermi tattili: i campi di testo devono avere almeno 16px, altrimenti iPhone e iPad ingrandiscono la pagina quando ci si scrive. */
@media (pointer: coarse), (max-width: 760px) {
  input, select, textarea, .cell-editor, .title-input, .info-form textarea { font-size: 16px !important; }
}

/* ---------- ricordami, verifica in due passaggi, chat ---------- */
.login-card .check-row { margin: 2px 0 8px; }
.login-hint { margin: 0 0 12px; }
.login-back { margin-top: 8px; }
.tfa p { margin: 0 0 10px; }
.tfa-key { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 18px; letter-spacing: .05em; padding: 10px 12px; background: #f1f3f4; border-radius: 8px; word-break: break-all; user-select: all; margin-bottom: 8px; }
.tfa-qr { display: block; max-width: 100%; height: auto; margin: 4px auto 12px; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 8px; }
.tfa-codes { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 16px; line-height: 1.7; padding: 10px 14px; background: #f1f3f4; border-radius: 8px; margin: 0 0 10px; user-select: all; }
.tfa-step { margin-top: 14px !important; }
.tfa-on { color: var(--ok); font-weight: 500; }
.tfa input[type="text"], .tfa input[type="password"] { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); }
.tfa .search-form input { flex: 1; }
.chat-btn { position: relative; }
.badge { position: absolute; top: -2px; right: -2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 17px; text-align: center; font-weight: 500; }
.chat-panel { position: fixed; right: 12px; top: 60px; bottom: 12px; width: 340px; z-index: 45; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.chat-panel[hidden] { display: none; }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.chat-sub { color: var(--muted); font-size: 12px; }
.chat-list { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-day { align-self: center; font-size: 11px; color: var(--muted); background: #f1f3f4; border-radius: 10px; padding: 1px 10px; margin: 4px 0; }
.chat-msg { max-width: 88%; align-self: flex-start; background: #f1f3f4; border-radius: 12px 12px 12px 3px; padding: 6px 10px; }
.chat-msg.is-mine { align-self: flex-end; background: var(--accent-weak); border-radius: 12px 12px 3px 12px; }
.chat-meta { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.chat-name { font-weight: 500; color: var(--text); }
.chat-del { margin-left: auto; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0 2px; opacity: .55; }
.chat-del:hover { opacity: 1; color: var(--danger); }
.chat-body { word-break: break-word; white-space: pre-wrap; margin-top: 1px; }
.chat-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; min-width: 0; height: 38px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 19px; background: var(--surface); }
.chat-form .btn { border-radius: 19px; min-width: 42px; justify-content: center; }
@media (max-width: 760px) {
  .chat-panel { inset: 0; width: auto; border-radius: 0; border: 0; z-index: 70; }
}

/* ---------- Home e file virtuali ---------- */
.toolbar[hidden], .formulabar[hidden], .gridbox[hidden], .tabsbar[hidden], .home[hidden] { display: none !important; }
.home { flex: 1; min-height: 0; overflow: auto; padding: 28px clamp(16px, 5vw, 56px); }
.home-head h2 { margin: 0 0 4px; font-size: 22px; font-weight: 500; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 18px; }
.file-card { position: relative; display: flex; flex-direction: column; gap: 6px; min-height: 148px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; text-align: left; cursor: pointer; box-shadow: 0 1px 2px rgba(60, 64, 67, .12); }
.file-card:hover, .file-card:focus-visible { box-shadow: var(--shadow); border-color: var(--accent); }
.file-icon { width: 42px; height: 42px; border-radius: 10px; background: var(--ok); color: #fff; display: grid; place-items: center; font-size: 20px; }
.file-name { font-size: 16px; font-weight: 500; margin-top: 6px; word-break: break-word; }
.file-meta { font-size: 12.5px; color: var(--muted); }
.file-acts { position: absolute; top: 8px; right: 8px; display: flex; gap: 2px; opacity: .55; }
.file-card:hover .file-acts, .file-acts:focus-within { opacity: 1; }
.file-new { align-items: center; justify-content: center; border-style: dashed; color: var(--muted); font-size: 15px; background: transparent; box-shadow: none; }
.file-new i { font-size: 24px; }

/* ---------- funzioni di formattazione per file ---------- */
.toolbar [hidden] { display: none !important; }
.color-pop { position: fixed; left: 50%; top: 40%; width: 0; height: 0; padding: 0; border: 0; opacity: 0; pointer-events: none; }
.feat-list { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 4px; }
.feat-item { display: flex; align-items: flex-start; gap: 10px; }
.feat-item input { margin-top: 3px; }
.feat-item small { display: block; color: var(--muted); }
.feat-row { display: flex; align-items: flex-start; gap: 12px; }
.feat-row .feat-item { flex: 1; min-width: 0; }
.feat-mgr { display: flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 13px; color: var(--muted); }
.feat-mgr.is-off { opacity: .5; }

/* ---------- controlli di base: nessun menu a tendina, campo o casella resta con l'aspetto del browser ----------
   (specificità zero: le regole dei singoli componenti li rifiniscono) */
:where(select, textarea, input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]):not([type="file"]):not([type="hidden"])) { border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); }
:where(input[type="checkbox"], input[type="radio"]) { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }

/* ---------- editor dei blocchi di statistiche ---------- */
.block-head { display: grid; grid-template-columns: minmax(190px, 260px) 1fr auto auto auto; gap: 6px; align-items: center; margin-bottom: 8px; }
.block-head select, .block-head input[type="text"] { height: 36px; padding: 0 10px; min-width: 0; width: 100%; }
@media (max-width: 640px) {
  .block-head { grid-template-columns: 1fr auto auto auto; }
  .block-head select { grid-column: 1 / -1; }
}
