:root {
  --bg: #f4f6f8; --panel: #fff; --text: #17202a; --muted: #5f6b78; --line: #dde3e9;
  --accent: #0f766e; --accent-ink: #fff; --danger: #b42318; --amber: #b54708; --green: #067647;
  --amber-bg: #fef0c7; --green-bg: #dcfae6; --red-bg: #fee4e2;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419; --panel: #172029; --text: #e6edf3; --muted: #93a1b0; --line: #2a3642;
    --accent: #2dd4bf; --accent-ink: #062521; --danger: #f97066; --amber: #fdb022; --green: #47cd89;
    --amber-bg: #3a2a08; --green-bg: #0b3320; --red-bg: #3d1210;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
h1 { font-size: 20px; margin: 4px 0 12px; } h2 { font-size: 18px; margin: 0; } h3 { font-size: 15px; margin: 24px 0 8px; }
a { color: var(--accent); }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.err { color: var(--danger); min-height: 1em; margin: 4px 0; }

input, select, button, .button { font: inherit; border-radius: 8px; }
input, select { padding: 8px 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); width: 100%; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; margin: 10px 0; font-weight: 500; }
label input, label select { margin-top: 4px; font-weight: 400; }
label.chk { display: inline-flex; gap: 6px; align-items: center; margin: 0; font-weight: 400; white-space: nowrap; }
label.chk input { width: auto; margin: 0; }
button, .button { padding: 8px 14px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; text-decoration: none; display: inline-block; }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.ghost { background: transparent; }
.danger-text { color: var(--danger); }
button.link { border: 0; background: none; color: var(--accent); padding: 6px 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.card.inline { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; padding: 14px 16px; }
.card.inline label { margin: 0; flex: 1 1 180px; }
.card + .card { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; } .row.end { justify-content: flex-end; margin-top: 16px; }

.auth { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 380px; }
.auth button.primary { width: 100%; margin-top: 6px; padding: 10px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.brand img { width: 26px; height: 26px; }
.qr { display: block; margin: 8px auto; width: 200px; height: 200px; background: #fff; border-radius: 8px; padding: 6px; }

.topbar { display: flex; align-items: center; gap: 20px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.topbar nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.topbar nav button { border: 0; background: none; padding: 8px 12px; color: var(--muted); }
.topbar nav button.active { color: var(--text); background: var(--bg); font-weight: 600; }
.me { display: flex; align-items: center; gap: 6px; color: var(--muted); }
main { padding: 20px; max-width: 1280px; margin: 0 auto; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=search] { max-width: 320px; }

table.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.grid th, .grid td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.grid tr:last-child td { border-bottom: 0; }
.grid td.actions { text-align: right; white-space: nowrap; }
.grid td.actions button { padding: 5px 10px; margin-left: 4px; }
.grid tr.warn td { background: var(--red-bg); }
.grid.audit td { font-size: 13px; }
.grid td.code { font: 600 16px ui-monospace, Consolas, monospace; letter-spacing: .1em; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: var(--bg); color: var(--muted); }
.pill.green { background: var(--green-bg); color: var(--green); } .pill.amber { background: var(--amber-bg); color: var(--amber); } .pill.red { background: var(--red-bg); color: var(--danger); }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.big-code { font: 700 40px ui-monospace, Consolas, monospace; letter-spacing: .2em; color: var(--accent); }
.dl { border-top: 1px solid var(--line); padding: 12px 0 4px; } .dl p { margin: 4px 0 8px; }

#v-viewer { position: fixed; inset: 0; display: flex; flex-direction: column; background: #0b0e12; }
.viewer-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.viewer-bar select { width: auto; padding: 6px 8px; }
.viewer-bar button { padding: 6px 10px; }
.spacer { flex: 1; }
.vw-body { flex: 1; display: flex; min-height: 0; }
#vw-files { width: 360px; max-width: 90vw; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; color: var(--text); }
#vw-files.drop { outline: 3px dashed var(--accent); outline-offset: -6px; }
.fp-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.fp-nav { padding: 8px 12px; } .fp-nav input { font: 12.5px ui-monospace, Consolas, monospace; padding: 6px 8px; }
.fp-nav button, .fp-head button { padding: 5px 9px; }
.fp-list { flex: 1; overflow: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.fp-row { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--line); cursor: default; }
.fp-row:hover { background: var(--bg); }
.fp-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fp-row.dir .nm { font-weight: 600; cursor: pointer; }
.fp-row .sz { color: var(--muted); font-size: 12px; white-space: nowrap; }
.fp-row button { padding: 3px 8px; font-size: 12px; }
.fp-note { padding: 12px; margin: 0; }
.fp-foot { padding: 10px 12px; } .fp-foot p { margin: 6px 0; }
.xfer { font-size: 12.5px; margin-top: 8px; }
.xfer .bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin-top: 3px; }
.xfer .bar i { display: block; height: 100%; background: var(--accent); width: 0; }
.xfer.err { color: var(--danger); }
#vw-stage { flex: 1; overflow: auto; position: relative; outline: none; display: grid; place-items: center; }
#vw-canvas { display: block; background: #000; cursor: default; }
#vw-canvas.fit { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
#vw-msg { position: absolute; inset: auto 0 40% 0; text-align: center; color: #cfd8e3; font-size: 16px; pointer-events: none; }

dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); width: min(440px, calc(100vw - 32px)); padding: 20px; }
dialog.wide { width: min(620px, calc(100vw - 32px)); }
.acc-mode { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.acc-pick { border: 1px solid var(--line); border-radius: 8px; margin: 10px 0; padding: 8px 12px 10px; }
.acc-pick legend { font-weight: 600; padding: 0 4px; }
.acc-pick:disabled { opacity: .5; }
.acc-list { display: flex; flex-direction: column; gap: 6px; max-height: 190px; overflow: auto; padding: 4px 0; }
.acc-list label.chk { white-space: normal; }
.acc-filter { margin: 4px 0 6px; padding: 6px 8px; }
dialog::backdrop { background: rgba(0,0,0,.45); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 10; }
.toast.err { background: var(--danger); color: #fff; }

/* client join page */
.join .steps { padding-left: 18px; } .join .steps li { margin: 6px 0; }
.join .codebox { font: 600 28px ui-monospace, Consolas, monospace; letter-spacing: .3em; text-align: center; }
.join pre { white-space: pre-wrap; word-break: break-all; background: var(--bg); padding: 10px; border-radius: 8px; font-size: 12.5px; }

/* computer list thumbnails */
.thumb { display: block; width: 112px; height: 63px; object-fit: contain; background: #0b0e12; border-radius: 6px; border: 1px solid var(--line); cursor: pointer; }
.thumb.none { display: grid; place-items: center; color: var(--muted); font-size: 11px; background: var(--bg); }
.grid td.shot { width: 124px; padding-top: 6px; padding-bottom: 6px; }
.grid td.shot button.link { font-size: 11.5px; padding: 2px 0 0; }
.grid .mname { cursor: pointer; }
.grid .mname:hover b { text-decoration: underline; }

/* computer details page */
.notice { background: var(--amber-bg); border-color: var(--amber); color: var(--text); margin-bottom: 12px; padding: 12px 16px; }
.md-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.md-head h2 { display: flex; align-items: center; gap: 8px; }
.md-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 12px; }
.md-shot { margin: 0; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.md-shot-box { background: #0b0e12; border-radius: 8px; min-height: 160px; display: grid; place-items: center; overflow: hidden; }
.md-shot-box img { display: block; width: 100%; height: auto; max-height: 520px; object-fit: contain; }
.md-shot-box p { color: #93a1b0; }
.md-updated { margin: 14px 2px 8px; gap: 10px; }
.md-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.md-cards .card, .md-glance { padding: 16px 18px; }
.md-cards .card + .card { margin-top: 0; }
.md-cards h3, .md-glance h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.meter { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin-top: 4px; max-width: 220px; }
.meter i { display: block; height: 100%; background: var(--accent); width: 0; }
.meter.hot i { background: var(--amber); }

@media (max-width: 900px) {
  .md-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  main { padding: 12px; }
  .grid th:nth-child(3), .grid td:nth-child(3), .grid th:nth-child(5), .grid td:nth-child(5) { display: none; }
  /* computers: keep dot, screen, name, last seen, actions */
  #t-machines .grid th, #t-machines .grid td { display: table-cell; }
  #t-machines .grid th:nth-child(4), #t-machines .grid td:nth-child(4), #t-machines .grid th:nth-child(5), #t-machines .grid td:nth-child(5),
  #t-machines .grid th:nth-child(6), #t-machines .grid td:nth-child(6) { display: none; }
  .thumb { width: 80px; height: 45px; }
  .grid td.shot { width: 88px; }
  .md-cards { grid-template-columns: 1fr; }
}
