:root {
  --primary: #1f6feb;
  --primary-ink: #ffffff;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #1f2937;
  --ink-2: #4b5563;
  --muted: #6b7280;
  --line: #e5e7eb;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --err: #b91c1c;
  --err-bg: #fee2e2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b; --surface: #171d26; --surface-2: #1d2430; --ink: #e5e7eb; --ink-2: #c3c8d0;
    --muted: #8b95a3; --line: #2a3340; --ok: #4ade80; --ok-bg: #11301e; --warn: #fbbf24; --warn-bg: #3a2c0b;
    --err: #f87171; --err-bg: #3b1515; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141b; --surface: #171d26; --surface-2: #1d2430; --ink: #e5e7eb; --ink-2: #c3c8d0;
  --muted: #8b95a3; --line: #2a3340; --ok: #4ade80; --ok-bg: #11301e; --warn: #fbbf24; --warn-bg: #3a2c0b;
  --err: #f87171; --err-bg: #3b1515; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; }
a { color: var(--primary); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.25; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12.5px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 500;
  min-height: 34px; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); border-color: var(--err); }
.btn.danger:hover { background: var(--err-bg); }
.btn.small { padding: 3px 10px; min-height: 28px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }

input[type=text], input[type=password], input[type=email], input[type=number], input[type=time], input[type=url], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); font: inherit; min-height: 36px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-weight: 500; margin-bottom: 4px; color: var(--ink-2); }
label.field > small { display: block; color: var(--muted); margin-top: 3px; }
label.check { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 10px; cursor: pointer; }
label.check input { margin-top: 3px; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.err { background: var(--err-bg); color: var(--err); border-color: transparent; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.err { background: var(--err); }

.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.alert.err { background: var(--err-bg); color: var(--err); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.info { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: center; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-left: 4px solid var(--primary); padding: 10px 12px; border-radius: 8px; box-shadow: var(--shadow); }
.toast span { flex: 1; }
.toast.error { border-left-color: var(--err); }
.toast.ok { border-left-color: var(--ok); }
.toast-x { background: none; border: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 0 4px; }

.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 900; padding: 16px; }
.modal { background: var(--surface); color: var(--ink); border-radius: 12px; box-shadow: var(--shadow); width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }

table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.list td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:hover td { background: var(--surface-2); }

/* Esploratore dei file della workstation (fileexplorer.js, dalla 0.1.34) */
.fx { display: flex; flex-direction: column; gap: 8px; }
.fx-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.fx-path { flex: 1 1 320px; min-width: 200px; padding: 5px 8px; }
.fx-chk { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; cursor: pointer; }
.fx-main { display: grid; grid-template-columns: minmax(150px, 210px) 1fr; gap: 10px; min-height: 280px; }
.fx-roots { display: flex; flex-direction: column; gap: 2px; overflow: auto; max-height: 60vh; }
.fx-root { text-align: left; background: transparent; border: 0; border-radius: 6px; padding: 6px 8px; color: var(--ink); cursor: pointer; font: inherit; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-root:hover { background: var(--surface-2); }
.fx-root.active { background: var(--surface-2); color: var(--primary); font-weight: 600; }
.fx-list { overflow: auto; max-height: 60vh; border: 1px solid var(--line); border-radius: 8px; }
.fx-list.drag { outline: 2px dashed var(--primary); outline-offset: -4px; }
.fx-list > p { padding: 10px 12px; margin: 0; }
.fx-table td, .fx-table th { padding: 5px 8px; }
.fx-table tr { cursor: default; }
.fx-table tr.sel td { background: var(--surface-2); }
.fx-table tr.fx-hidden td { opacity: .6; }
.fx-cb { width: 28px; }
.fx-size, .fx-date { white-space: nowrap; color: var(--ink-2); }
.fx-name { color: var(--ink); text-decoration: none; word-break: break-all; }
.fx-name:hover { color: var(--primary); text-decoration: underline; }
.fx-err { color: var(--err); }
.fx-xfers { display: flex; flex-direction: column; gap: 6px; }
.fx-xfer-head { display: flex; justify-content: space-between; gap: 8px; }
.fx-bar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 2px; }
.fx-bar-fill { height: 100%; width: 0; background: var(--primary); transition: width .2s; }
.fx-xfer.ok .fx-bar-fill { background: var(--ok); }
.fx-xfer.err .fx-bar-fill { background: var(--err); }
@media (max-width: 700px) { .fx-main { grid-template-columns: 1fr; } .fx-roots { flex-direction: row; flex-wrap: wrap; max-height: none; } }
.modal.wide { width: min(1100px, 100%); }
