:root {
  --bg: #0e1014;
  --bg2: #161a22;
  --bg3: #1f2530;
  --fg: #e6e6e6;
  --muted: #9aa3b2;
  --accent: #4f8cff;
  --ok: #2ecc71;
  --bad: #e74c3c;
  --border: #2a2f3a;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.35 system-ui, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err   { color: var(--bad); }
a { color: var(--accent); }

button {
  background: var(--accent); color: white; border: 0; padding: 7px 12px;
  border-radius: 6px; cursor: pointer; font: inherit;
}
button:hover { filter: brightness(1.1); }
button.ghost { background: transparent; border: 1px solid var(--border); color: var(--fg); }
button.ghost:hover { background: var(--bg3); filter: none; }
button.ghost.active { background: var(--accent); color: white; border-color: var(--accent); }

.pill {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  background: #2a2f3a; color: var(--muted); font-size: 12px;
}
.pill.ok  { background: #14361f; color: var(--ok); }
.pill.bad { background: #3a1717; color: var(--bad); }

.download-link {
  display: inline-block; padding: 6px 10px; border-radius: 6px;
  border: 1px solid var(--border); text-decoration: none;
  color: var(--fg); font-size: 13px;
}
.download-link:hover { background: var(--bg3); }

/* ============ LIST VIEW ============ */
.list-view {
  height: 100%;
  display: flex; flex-direction: column;
  padding: 24px 24px 80px;
  overflow: auto;
}
.list-header {
  display: flex; align-items: baseline; gap: 14px;
  padding-bottom: 18px; border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
}
.list-header h1 { margin: 0; font-size: 22px; font-weight: 600; }
.list-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.multi-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: transform .08s ease, border-color .15s ease, background .15s ease;
  display: flex; flex-direction: column; gap: 6px;
  user-select: none;
}
.card:hover {
  border-color: var(--accent);
  background: var(--bg3);
  transform: translateY(-1px);
}
.card.selected {
  border-color: var(--accent);
  background: var(--bg3);
  box-shadow: 0 0 0 2px rgba(79, 140, 255, 0.25);
}
.card .name {
  font-weight: 600; font-size: 16px;
  display: flex; align-items: center; gap: 8px;
}
.card .name::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
}
.card .meta { color: var(--muted); font-size: 12px; }
.card .badge { color: var(--muted); font-size: 11px; }

.hint { margin: 30px auto; text-align: center; }

/* ============ VIEWER VIEW (single) ============ */
.viewer-view {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
}
.vtop {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 6px 10px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
.vtop .agent-title { font-weight: 600; }
.vtop .ctrl { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; }
.vtop .ctrl input {
  width: 4em;
  background: #0b0d12; border: 1px solid var(--border);
  border-radius: 4px; padding: 3px 6px; color: var(--fg);
}
.vtop select {
  background: #0b0d12; border: 1px solid var(--border);
  color: var(--fg); border-radius: 4px; padding: 4px 6px;
}
.vtop #info { margin-left: auto; }

.viewer {
  position: relative;
  background: #000;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
canvas#screen {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto; height: auto;
  image-rendering: pixelated;
  outline: none;
  cursor: none;
}
canvas#screen:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); pointer-events: none;
}

.drop-hint {
  position: absolute; inset: 0;
  background: rgba(15, 22, 36, 0.85);
  border: 3px dashed var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); font-size: 18px; font-weight: 600;
  pointer-events: none; z-index: 10;
}

/* ============ MULTI VIEW ============ */
.multi-view {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
}
.multi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 8px;
  padding: 8px;
  background: #000;
  overflow: auto;
}
.mpane {
  background: #0b0d12;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  display: flex; flex-direction: column;
  position: relative;
}
.mpane.focused { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.mpane-top {
  display: flex; align-items: center;
  padding: 4px 8px; background: var(--bg2);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.mpane-title { flex: 1; font-weight: 600; }
.mpane-close { padding: 2px 8px; font-size: 14px; line-height: 1; }
.mpane-canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #000;
  image-rendering: pixelated;
  cursor: none;
}

/* Cursor overlay (real OS cursor, mirrored from the agent) */
.cursor-overlay {
  position: absolute;
  left: 0; top: 0;
  pointer-events: none;
  image-rendering: pixelated;
  z-index: 5;
  user-select: none;
}

/* ============ Transfers panel ============ */
.transfers {
  position: absolute;
  right: 10px; bottom: 10px;
  background: rgba(15, 22, 36, 0.95);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 280px;
  max-width: 380px;
  z-index: 20;
  font-size: 12px;
}
.trow {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  align-items: center;
  padding: 3px 0;
}
.tname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tprog { color: var(--muted); }

/* ============ Password modal ============ */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 22px;
  min-width: 320px;
}
.modal h3 { margin: 0 0 6px; }
.modal input {
  width: 100%;
  padding: 8px 10px;
  background: #0b0d12;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
  font: inherit;
  margin: 10px 0 6px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
