:root {
  --side: rgba(238, 241, 247, 0.62);
  --surface: #ffffff;
  --surface-2: #f6f7fa;
  --line: #e8eaef;
  --line-2: #dfe2e8;
  --text: #1c1f26;
  --text-2: #6b7280;
  --text-3: #9aa0ab;
  --hover: #f2f5fb;
  --sel: #e7efff;
  --sel-line: #b9d0ff;
  --accent: #2f6fed;
  --accent-2: #2559c9;
  --accent-soft: #eaf1ff;
  --ok: #16a34a;
  --off: #b4b9c3;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 24px 64px rgba(16, 24, 40, 0.22);
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --side: rgba(26, 27, 32, 0.6);
    --surface: #1e2026;
    --surface-2: #24262d;
    --line: #2f323a;
    --line-2: #3a3d46;
    --text: #ecedf2;
    --text-2: #a0a4ae;
    --text-3: #727782;
    --hover: #282b33;
    --sel: #213559;
    --sel-line: #36589a;
    --accent: #5b8ff9;
    --accent-2: #7ba5ff;
    --accent-soft: #22314f;
    --off: #5c616c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: transparent; }
body {
  font: 13px/1.4 "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.drag { -webkit-app-region: drag; }
.no-drag, button, input, .nav, .crumbs { -webkit-app-region: no-drag; }
svg.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* minmax(0, …) e min-height: 0 tengono tutto dentro la finestra: così scorre la lista, non la pagina */
.app { display: grid; grid-template-columns: 252px 1fr; grid-template-rows: minmax(0, 1fr); height: 100vh; }

/* ---------- barra laterale ---------- */
.sidebar { display: flex; flex-direction: column; background: var(--side); min-width: 0; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 18px; font-weight: 650; font-size: 15px; letter-spacing: 0.1px; }
.brand-mark { width: 28px; height: 28px; }
.nav { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 10px 12px; }
.nav-title { display: flex; align-items: center; justify-content: space-between; margin: 14px 8px 6px; font-size: 11.5px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.6px; }
.nav-title .host { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text-3); }
.nav-item { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 6px 10px; border-radius: 8px; color: var(--text); text-align: left; }
.nav-item:hover { background: rgba(127, 140, 170, 0.14); }
.nav-item.active { background: var(--surface); box-shadow: var(--shadow); }
.nav-item.drop { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.nav-item .lbl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .muted { flex: none; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; color: var(--text-3); }
.nav-item .ic { color: var(--text-2); }
.nav-item.sub { padding-left: 30px; min-height: 30px; }
.nav-item .chev { width: 14px; height: 14px; color: var(--text-3); transition: transform 0.15s; }
.nav-item.open .chev { transform: rotate(90deg); }
.drive-meta { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.meter { height: 4px; border-radius: 4px; background: rgba(127, 140, 170, 0.22); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.meter.full i { background: var(--danger); }
.chip { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 5px; background: rgba(127, 140, 170, 0.18); color: var(--text-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--off); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15); }
.side-foot { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 14px; }
.side-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 38px; border-radius: 9px; background: var(--surface); box-shadow: var(--shadow); font-weight: 600; color: var(--accent); }
.side-btn:hover { background: var(--accent-soft); }
.side-mini { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border-radius: 8px; color: var(--text-2); font-weight: 600; font-size: 12.5px; }
.side-mini:hover { background: var(--hover); color: var(--text); }
.side-mini .ic { width: 16px; height: 16px; }

/* ---------- area principale ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 0 10px 10px 0; }
.titlebar { height: 44px; display: flex; align-items: center; justify-content: flex-end; padding-right: 146px; }
.title-actions { display: flex; gap: 4px; }
.tb-btn { position: relative; display: grid; place-items: center; width: 34px; height: 30px; border-radius: 7px; color: var(--text-2); }
.tb-btn:hover { background: rgba(127, 140, 170, 0.16); color: var(--text); }
.tb-btn.on { color: var(--accent); background: var(--accent-soft); }
.tb-btn .badge { position: absolute; top: 2px; right: 2px; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; line-height: 15px; }
.panes { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 10px; min-height: 0; }
.panes.split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; }
.panes.split .pane.active { border-color: var(--sel-line); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
.pane-bar { display: flex; align-items: center; gap: 10px; padding: 12px 14px 8px; }
.btn-row { display: flex; align-items: center; gap: 4px; }
.icon-btn, .tool { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); }
.icon-btn:hover:not(:disabled), .tool:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.icon-btn:disabled, .tool:disabled { opacity: 0.4; cursor: default; }
.tool.on { color: var(--accent); border-color: var(--sel-line); background: var(--accent-soft); }
/* le briciole non si schiacciano: se non ci stanno, si vede la fine del percorso e l'inizio sfuma */
.crumbs { flex: 1 1 auto; min-width: 90px; display: flex; align-items: center; gap: 2px; height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); overflow: hidden; white-space: nowrap; }
.crumbs.cut { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 28px); }
.crumb { flex: none; padding: 3px 6px; border-radius: 6px; color: var(--text-2); max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.crumb:hover { background: var(--hover); color: var(--text); }
.crumb:last-child { color: var(--text); font-weight: 600; }
.crumb-sep { width: 14px; height: 14px; color: var(--text-3); flex: none; }
.search { display: flex; align-items: center; gap: 6px; flex: 0 1 220px; min-width: 96px; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); color: var(--text-3); }
.search:focus-within { border-color: var(--accent); background: var(--surface); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; }
.search .ic { width: 16px; height: 16px; }
.pane-tools { display: flex; justify-content: space-between; padding: 0 14px 10px; }
.tool .ic { width: 17px; height: 17px; }

.list-head, .row { display: grid; grid-template-columns: minmax(200px, 1fr) 110px 150px 150px; align-items: center; column-gap: 12px; }
.list-head { margin: 0 14px; padding: 0 12px; height: 34px; border-radius: 8px; background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--text-2); }
.list-head button { text-align: left; padding: 0; display: flex; align-items: center; gap: 4px; height: 100%; }
.list-head button.sorted { color: var(--accent); }
.list-head .ic { width: 12px; height: 12px; }
/* pannelli stretti: sotto 780 px via il tipo, sotto 520 px resta nome e dimensione */
.narrow .list-head, .narrow .row { grid-template-columns: minmax(140px, 1fr) 84px 120px; }
.narrow [data-sort="tipo"], .narrow .c-type { display: none; }
.tiny .list-head, .tiny .row { grid-template-columns: minmax(120px, 1fr) 76px; }
.tiny [data-sort="mtime"], .tiny .c-date { display: none; }
.tiny .pane-bar { gap: 6px; padding: 10px 10px 8px; }
.tiny .crumbs { min-width: 70px; }
.tiny .search { flex-basis: 120px; min-width: 44px; }
.tiny .pane-tools { padding: 0 10px 10px; }
.tiny .list-head { margin: 0 10px; }
.tiny .list { padding: 4px 10px 10px; }
.list { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 14px 10px; outline: none; }
.list.drop { background: var(--accent-soft); }
.row { height: 40px; padding: 0 12px; border-radius: 8px; border: 1px solid transparent; }
.row:hover { background: var(--hover); }
.row.sel { background: var(--sel); border-color: var(--sel-line); }
.row.drop { border-color: var(--accent); background: var(--accent-soft); }
.c-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.c-name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-size, .c-type, .c-date { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-size { text-align: left; }
.fi { width: 24px; height: 24px; flex: none; }

.list.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 8px; align-content: start; padding-top: 10px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 8px 10px; border-radius: 10px; border: 1px solid transparent; text-align: center; }
.tile:hover { background: var(--hover); }
.tile.sel { background: var(--sel); border-color: var(--sel-line); }
.tile.drop { border-color: var(--accent); background: var(--accent-soft); }
.tile .thumb { width: 92px; height: 76px; display: grid; place-items: center; }
.tile .thumb .fi { width: 64px; height: 64px; }
.tile .thumb img { max-width: 92px; max-height: 76px; border-radius: 6px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); object-fit: cover; }
.tile .nm { width: 100%; font-size: 12.5px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }

.pane-foot { display: flex; justify-content: space-between; gap: 12px; padding: 9px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-2); }

/* stati vuoti, errori, caricamento */
.empty { display: grid; place-items: center; align-content: center; gap: 10px; height: 100%; min-height: 220px; padding: 24px; text-align: center; color: var(--text-2); }
.empty .ic { width: 40px; height: 40px; stroke-width: 1.3; color: var(--text-3); }
.empty b { color: var(--text); font-size: 14px; }
.empty p { margin: 0; max-width: 420px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 34px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 600; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn:disabled { opacity: 0.55; cursor: default; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line-2); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* home: Questo PC e dispositivi */
.home { padding: 6px 4px 20px; }
.home h3 { margin: 14px 4px 10px; font-size: 13px; color: var(--text-2); font-weight: 600; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); text-align: left; }
.card:hover { border-color: var(--sel-line); background: var(--hover); }
.card.drop { border-color: var(--accent); background: var(--accent-soft); }
.card .big { width: 40px; height: 40px; color: var(--accent); stroke-width: 1.5; }
.card .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.card .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 8px; }
.card .s { font-size: 12px; color: var(--text-2); }
.card.add { border-style: dashed; color: var(--accent); justify-content: center; font-weight: 600; min-height: 74px; }

/* ---------- trasferimenti ---------- */
.dock { position: fixed; right: 22px; bottom: 22px; width: 380px; max-height: 60vh; display: flex; flex-direction: column; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); overflow: hidden; z-index: 20; }
body.dragging .dock { pointer-events: none; opacity: 0.35; transition: opacity 0.15s; }
.dock-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 650; }
.dock-head .sp { flex: 1; }
.link { color: var(--accent); font-weight: 600; font-size: 12px; padding: 4px 6px; border-radius: 6px; }
.link:hover { background: var(--accent-soft); }
.dock-list { overflow-y: auto; padding: 6px 8px 8px; }
.tr { padding: 10px 8px; border-radius: 10px; }
.tr + .tr { border-top: 1px solid var(--line); border-radius: 0; }
.tr-top { display: flex; align-items: center; gap: 10px; }
.tr-top .nm { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-route { margin: 2px 0 8px 28px; font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 6px; margin-left: 28px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 6px; transition: width 0.2s; }
.tr.fatto .bar i { background: var(--ok); }
.tr.errori .bar i, .tr.annullato .bar i { background: var(--danger); }
.tr-info { display: flex; justify-content: space-between; margin: 6px 0 0 28px; font-size: 12px; color: var(--text-2); }
.tr-err { margin: 6px 0 0 28px; font-size: 12px; color: var(--danger); white-space: pre-line; max-height: 70px; overflow: auto; user-select: text; }
.tr .x { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; color: var(--text-3); }
.tr .x:hover { background: var(--hover); color: var(--text); }
.tr .state-ic { color: var(--accent); }
.tr.fatto .state-ic { color: var(--ok); }
.tr.errori .state-ic, .tr.annullato .state-ic { color: var(--danger); }

/* ---------- finestre di dialogo ---------- */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(15, 20, 30, 0.32); z-index: 50; animation: fade 0.12s ease-out; }
@keyframes fade { from { opacity: 0; } }
.dialog { width: 460px; max-width: calc(100vw - 32px); max-height: calc(100vh - 48px); overflow-y: auto; padding: 22px 24px 20px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-lg); animation: pop 0.14s ease-out; }
.dialog.wide { width: 560px; }
@keyframes pop { from { transform: translateY(6px) scale(0.98); opacity: 0; } }
.dialog h2 { margin: 0 0 6px; font-size: 17px; font-weight: 650; }
.dialog .sub { margin: 0 0 16px; color: var(--text-2); }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field input[type="text"], .field input[type="password"] { height: 36px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); outline: 0; user-select: text; }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg button { display: flex; align-items: center; justify-content: center; gap: 8px; height: 38px; border-radius: 8px; border: 1px solid var(--line-2); color: var(--text-2); font-weight: 600; }
.seg button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; margin-top: 16px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.hint { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); color: var(--text-2); font-size: 12.5px; line-height: 1.5; }
.err { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: rgba(220, 38, 38, 0.08); color: var(--danger); font-size: 12.5px; white-space: pre-line; }
.found { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; max-height: 150px; overflow-y: auto; }
.found button { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); text-align: left; }
.found button:hover { border-color: var(--accent); background: var(--accent-soft); }
.found .ip { margin-left: auto; color: var(--text-3); font-size: 12px; }
.scan-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; color: var(--text-2); font-size: 12.5px; }

/* ---------- link da condividere ---------- */
.field select, .field input[type="datetime-local"], .lk select { height: 36px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; outline: 0; }
.field select:focus, .field input[type="datetime-local"]:focus, .lk select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input[type="datetime-local"] { margin-top: 6px; }
.field input[readonly] { background: var(--surface-2); }
.dialog .bar { margin: 14px 0 8px; height: 8px; }
.links { display: flex; flex-direction: column; gap: 8px; max-height: 52vh; overflow-y: auto; }
.lk { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.lk b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lk .meta { color: var(--text-2); font-size: 12.5px; }
.lk .acts { grid-row: 1 / span 2; grid-column: 2; display: flex; gap: 6px; align-items: center; }
.lk .btn, .lk select { height: 30px; padding: 0 10px; font-size: 12.5px; }
.lk .btn .ic { width: 14px; height: 14px; }

/* ---------- account ---------- */
.dialog h3 { margin: 18px 0 2px; font-size: 13.5px; font-weight: 650; }
.voci { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.voce { display: grid; grid-template-columns: minmax(0, 1.2fr) 1fr 1fr; gap: 8px; align-items: center; }
.voce .chi { display: flex; align-items: center; gap: 8px; min-width: 0; }
.voce .chi b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.voce .chi small { display: block; color: var(--text-3); font-size: 11.5px; }
.voce input { height: 34px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; outline: 0; min-width: 0; }
.voce input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.codice { margin-top: 12px; padding: 14px; border-radius: 10px; background: var(--surface-2); font: 600 17px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: 0.04em; text-align: center; user-select: all; word-spacing: 0.3em; }
.link-like { color: var(--accent); font-weight: 600; text-decoration: underline; cursor: pointer; }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); padding: 10px 16px; border-radius: 10px; background: #1f2430; color: #fff; box-shadow: var(--shadow-lg); z-index: 60; animation: fade 0.15s; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(127, 140, 170, 0.35); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(127, 140, 170, 0.55); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Mac: font di sistema, spazio per i tre pallini della finestra, niente pulsanti di Windows a destra ---------- */
.mac body, body.mac { font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif; }
.mac .brand { padding-left: 90px; }
.mac .titlebar { padding-right: 10px; }

/* verifica in due passaggi: QR per l'app del telefono */
.qr { display: grid; place-items: center; margin: 14px 0 6px; padding: 12px; border-radius: 12px; background: #fff; }
.qr svg { width: 196px; height: 196px; }
.segreto { font: 600 13px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: 0.08em; word-break: break-all; user-select: all; text-align: center; color: var(--text-2); }
